I have a golang project which includes windows-specific code. When working on this project from vscode running on macOS, I'm getting the following warning opening file getFileCreationTime_windows.go
:
This file is within module ".", which is not included in your workspace. To fix this problem, you can add a go.work file that uses this directory. See the documentation for more information on setting up your workspace: https://github.com/golang/tools/blob/master/gopls/doc/workspace.md. go list
It's not clear to me what should I do with this warning. I'm not using multiple modules, it's a simple application project.
The Go language server does not support build tags very well. See the discussions in this issue: x/tools/gopls: improve handling for build tags #29202.
You can ignore this warning message.
If you need completions, diagnostics, etc for this file, you can choose one of the following approaches:
If you only need to edit files for other platforms occasionally, you can start VSCode like this:
If you are developing codes for other platforms most of the time and you don't want to specify
GOOS
every time, you can save it to the.vscode/settings.json
file: