在GOPATH下找不到包
我正在尝试使用在GOPATH下找不到包,go,gopath,Go,Gopath,我正在尝试使用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
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
,这是我感兴趣的环境变量:
GOPATH="/Users/theo/go-workspace"
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"
请注意,我是zsh
,我正在将GOPATH
导出到.zshrc
文件中,如下所示:
export GOPATH=HOME/go-workspace
欢迎提出任何意见
*更新*
根据要求,这是调用models
包的一段代码:
import (
"database/sql"
"log"
"github.com/arschles/go-in-5-minutes/episode13/models"
_ "github.com/mxk/go-sqlite/sqlite3"
)
您只能设置gopath一次,每次更改包时都必须重置它。把它想象成一个虚拟世界。一种解决方法是在全球范围内安装软件包,或者使用gvm之类的工具安装软件包。软件包是否位于这些位置?我不熟悉glide,但听起来你需要先运行
go get
。不,这就是问题所在。包裹不在那里。Glide是一个供应商软件包管理器,如PHP composer。当Glide显示错误时,您正在运行什么命令?Glide安装
,它安装所有依赖项go get
完成了该工作,但我想知道抛出的消息是否表明我的计算机中存在错误设置。嗨,你能分享你的代码吗?看起来很奇怪,你的包github.com/thitami/go-in-5-minutes/eposode13/models
正在寻找github.com/arschles/go-in-5-minutes/eposode13/models