我有一个Golang项目,我使用的版本是1.13。我的模块是托管在我的私人回购。我的回购开始于:
module <Private-Repo>-service
go 1.13还有一些Repos是来自Github和go包的。我正在使用Golang的vs代码包
谷歌的
围棋团队
我有这样的想法:
GOROOT="/usr/local/go"
GOPATH="/home/{User}/go"
GOPRIVATE=<Private-Repo-URL>我复制Repo的文件夹在/home/{User}/go/src/
但我无法解决这个问题,它是说:
could not import github.com/golang/mock/gomock (cannot find package "github.com/golang/mock/gomock" in any of
/usr/local/go/src/github.com/golang/mock/gomock (from $GOROOT)
/home/{User}/go/src/github.com/golang/mock/gomock (from $GOPATH))compilerBrokenImport所以我需要在代码中解决这个问题。
发布于 2021-10-18 06:16:17
如果问题仍然存在,请先尝试:
命令行中的
go.mod/gomock)一旦go构建在命令行中工作,您就可以切换回VSCode,并确认它在那里也很好。
发布于 2021-10-18 07:34:39
不要将代码直接存储在$GOPATH中,而是尝试将代码存储在另一个目录中,即github.com/{github-username}/。
发自:
/home/{User}/go/src/至:
/home/{User}/go/src/github.com/{github-username}/https://stackoverflow.com/questions/69611142
复制相似问题