Goland 未检测到从 github.com 导入的模块。这些模块在 $GOPATH/pkg/mod 目录中可用,但导入没有被解析。 vendor 目录也下载了所有包。
戈兰版本:2019.3.3
围棋版本:围棋 1.13.7
在首选项下:
- GOROOT is set to /usr/local/go
- Global GOPATH is set to /Users/xyz/go
- Go module integration is enabled
- Enable vendoring support is enabled.
- dep integration is not enabled.
项目结构:
- project-name
- bin
- build
- cmd
- serviced
- main.go
- internal
- config
- config.go
- vendor
- github.com
- .....
- go.mod
- External Libraries
- GO SDK 1.13.7
值得一提的是,Goland 并没有下载外部库下的 Go 模块。
最佳答案
全部下载src
图书馆到$GOPATH/pkg/mod
go mod download
创建 vendor
目录 ( <project-name>/vendor
) 使用 vendor
旗帜go mod vendor
1.14版本之前使用
vendor
构建旗帜go build -mod=vendor
或者GOFLAGS="-mod=vendor" go build
1.14 及更高版本 (Go Modules)When the main module contains a top-level
vendor
directory and itsgo.mod
file specifies go 1.14 or higher, the go command now defaults to-mod=vendor
for operations that accept that flag. A new value for that flag,-mod=mod
, causes the go command to instead load modules from the module cache (as when no vendor directory is present).
在
project-name
中执行目录(其中包含 go.mod
)
关于GoLand 没有检测到 $GOPATH/pkg/mod 下的 vendor 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60910866/