Go 檔案結構
/go
/go : installation, $GOROOT
/projects : $GOPATH
/pkg
/src : add projects here
/myMod1
/go.mod
/main.go
` /myMod2
/go.mod
/main.go如果未按照這此結構,VS code會找不到package
Error message
gopls was not able to find modules in your workspace.
When outside of GOPATH, gopls needs to know which modules you are working on.
You can fix this by opening your workspace to a folder inside a Go module, or
by using a go.work file to specify multiple modules.
See the documentation for more information on setting up your workspace:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md
Go模組初始化
~/go/projects/src/myMod1$ go mod init go.example/demo-1
沒有留言:
張貼留言