嘗試使用 1.5 版在 go lang 中構建我的項目并GO15VENDOREXPERIMENT="1"打開以確保我在本地尋找供應商。我的結構是:apps_api main.go build.sh src controllers models views vendor github.com golang.org .....build.sh 包含export GO15VENDOREXPERIMENT="1"export GOPATH=`pwd`go build .控制器文件示例import ( "models" "views" "github.com/gin-gonic/gin")但是我收到很多錯誤,說找不到包,請參見下面的示例src/controllers/app-versions.go:10:2: cannot find package "github.com/asaskevich/govalidator" in any of: /Users/ereeve/.gvm/gos/go1.5/src/github.com/asaskevich/govalidator (from $GOROOT) /Users/ereeve/Documents/gocode/src/apps_api/src/github.com/asaskevich/govalidator (from $GOPATH)src/controllers/index.go:4:2: cannot find package "github.com/chnlr/baseurl" in any of: /Users/ereeve/.gvm/gos/go1.5/src/github.com/chnlr/baseurl (from $GOROOT) /Users/ereeve/Documents/gocode/src/apps_api/src/github.com/chnlr/baseurl (from $GOPATH)如果我將這些行添加到我的 build.sh 文件中,它將構建,但我不想使用 go get 因為我在我的項目中使用 go 1.5 與本地供應商以避免依賴關系。# go get github.com/gin-gonic/gin# go get github.com/go-sql-driver/mysql# go get github.com/rif/cache2go....任何想法我做錯了什么?
1 回答

收到一只叮咚
TA貢獻1821條經驗 獲得超5個贊
IIRC,GO15VENDOREXPERIMENT
只有當你正在構建的包在里面時才會工作$GOPATH/src
,所以設置
export GOPATH=`pwd`
在你build.sh
讓它失敗。如果你把你的apps_api
內心說~/fakegopath/src/
和跑
env GOPATH="${HOME}/fakegopath/src/" GO15VENDOREXPERIMENT="1" go build .
它應該工作。
- 1 回答
- 0 關注
- 170 瀏覽
添加回答
舉報
0/150
提交
取消