【发布时间】:2020-04-04 23:30:47
【问题描述】:
构建(失败):
GO111MODULE=off go build -o diameter
[pceuser@pincb-brm02 src]$ echo $GOPATH
/home/pceuser/policy-control-engine
[pceuser@pincb-brm02 src]$ pwd
/home/pceuser/policy-control-engine/src
[pceuser@pincb-brm02 src]$ ls
backupgx config.go data.csv go.mod gx.go model.go README redis_test.go stats.go ccr.go config.yml 直径 go.sum Makefile pcediam redis.go server.go vendor
[pceuser@pincb-brm02 src]$ cd vendor
[pceuser@pincb-brm02 vendor]$ ls
github.com golang.org gopkg.in modules.txt
构建错误:
ccr.go:8:2: cannot find package
"github.com/fiorix/go-diameter/v4/diam" in any of:
/usr/local/go/src/github.com/fiorix/go-diameter/v4/diam (from
$GOROOT)
/home/pceuser/policy-control-engine/src/github.com/fiorix/go-diameter/v4/diam
(from $GOPATH)
ccr.go:9:2: cannot find package
"github.com/fiorix/go-diameter/v4/diam/avp" in any of:
/usr/local/go/src/github.com/fiorix/go-diameter/v4/diam/avp (from
$GOROOT)
/home/pceuser/policy-control-engine/src/github.com/fiorix/go-diameter/v4/diam/avp
(from $GOPATH)
gx.go:11:2: cannot find package
"github.com/fiorix/go-diameter/v4/diam/datatype" in any of:
/usr/local/go/src/github.com/fiorix/go-diameter/v4/diam/datatype
(from $GOROOT)
/home/pceuser/policy-control-engine/src/github.com/fiorix/go-diameter/v4/diam/datatype
(from $GOPATH)
ccr.go:6:2: cannot find package
"github.com/fiorix/go-diameter/v4/diam/sm" in any of:
/usr/local/go/src/github.com/fiorix/go-diameter/v4/diam/sm (from
$GOROOT)
/home/pceuser/policy-control-engine/src/github.com/fiorix/go-diameter/v4/diam/sm
(from $GOPATH)
redis.go:6:2: cannot find package "github.com/go-redis/redis" in any
of: /usr/local/go/src/github.com/go-redis/redis (from $GOROOT)
/home/pceuser/policy-control-engine/src/github.com/go-redis/redis
(from $GOPATH)
config.go:6:9: cannot find package "gopkg.in/yaml.v2" in any of:
/usr/local/go/src/gopkg.in/yaml.v2 (from $GOROOT)
/home/pceuser/policy-control-engine/src/gopkg.in/yaml.v2 (from
$GOPATH)
注意:我在我的 https://github.com/fiorix/go-diameter 中做了一些更改 供应商依赖文件夹,但我仍然无法编译它。
【问题讨论】:
-
你试过
go build -mod=vendor吗?这将从vendor包中加载您的依赖项,而不是在全局 GOPATH 中找到它们 -
您可以尝试一些技巧,甚至可能会奏效,但要真正了解它发生的确切原因,我需要一些额外的信息。您能否检查一下供应商目录中是否存在上述软件包。另外,分享
go env和go version的输出。
标签: go go-modules