I have a Go project that uses build tags.
When I run gopls it gives this warning:
If this file contains build tags, try adding "-tags=<build tag>" to your gopls "buildFlags" configuration (see (https://github.com/golang/tools/blob/master/gopls/doc/settings.md#buildflags-string).
Which is fine, that page says that I can add “-tags=wireinject” to the build.buildFlags setting.
After some experimentation, adding to the LSP config as follows works:
"gopls": {
"enabled": true,
"command": ["gopls"],
"selector": "source.go",
"initializationOptions": {
"experimentalWorkspaceModule": false,
"buildFlags": ["-tags=wireinject"],
},
},
Note the bare “buildFlags”, rather than what I expected which was “build.buildFlags”.
However I can’t get it to work in project settings applied to the .sublime-project file.
From the comments on Project-specific package settings? I thought this would work but it doesn’t:
"settings": {
"LSP": {
"gopls": {
"initializationOptions": {
"buildFlags": ["-tags=wireinject"],
},
}
}
}
Any help appreciated, thanks.