我正在尝试用glide安装我的项目的依赖项,但不幸的是,它在以下消息中失败了:
main.go:7:2: cannot find package "github.com/arschles/go-in-5-minutes/episode13/models" in any of:
/Users/theo/go-workspace/src/github.com/thitami/go-in-5-minutes/episode13/vendor/github.com/arschles/go-in-5-minutes/episode13/models (vendor tree)
/usr/local/Cellar/go/1.8.3/libexec/src/github.com/arschles/go-in-5-minutes/episode13/models (from $GOROOT)
/Users/theo/go-workspace/src/github.com/arschles/go-in-5-minutes/episode13/models (from $GOPATH)运行一个go env,这是我感兴趣的env变量:
GOPATH="/Users/theo/go-workspace"
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"请注意,我是zsh,我正在导出.zshrc文件中的GOPATH,如下所示:
export GOPATH=HOME/go-workspace任何想法都会受到赞赏。
* UPDATE *
根据请求,这是调用models包的代码段:
import (
"database/sql"
"log"
"github.com/arschles/go-in-5-minutes/episode13/models"
_ "github.com/mxk/go-sqlite/sqlite3"
)发布于 2017-07-15 16:38:21
您只能设置一次gopath,每次更改包时都必须重新设置它。把它想象成一个虚拟的人。一种方法是全局安装软件包,或者使用类似gvm之类的方法。
https://stackoverflow.com/questions/45084909
复制相似问题