doushi9729
doushi9729
2017-07-13 15:19
浏览 127
已采纳

在GOPATH下找不到软件包

I am trying to install the dependencies of my project with glidebut unfortunately it fails with the following message:

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)

Running a go env, this is my env variables of interest:

GOPATH="/Users/theo/go-workspace"
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"

Please be advised that I am zsh and I am exporting the GOPATH inside the .zshrc file like this:

export GOPATH=HOME/go-workspace

Any ideas are appreciated

* UPDATE *

As requested this is the piece of code with the call to the models package:

import (
    "database/sql"
    "log"

    "github.com/arschles/go-in-5-minutes/episode13/models"
    _ "github.com/mxk/go-sqlite/sqlite3"
)

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用 glide 安装项目的依赖项,但不幸的是,它失败并失败了 以下消息:

  main.go:7:2:在任何位置都找不到包“ github.com/arschles/go-in-5-minutes/episode13/models” 的:
 /Users/theo/go-workspace/src/github.com/thitami/go-in-5-minutes/episode13/vendor/github.com/arschles/go-in-5-minutes/episode13/models  (供应商树)
 /usr/local/Cellar/go/1.8.3/libexec/src/github.com/arschles/go-in-5-minutes/episode13/models(来自$ GOROOT)
 / Users /  theo / go-workspace / src / github.com / arschles / go-in-5-minutes / episode13 / models(来自$ GOPATH)
   
 
 

运行< code> go env ,这是我感兴趣的env变量:

  GOPATH =“ / Users / theo / go-workspace” 
GOROOT =“ / usr /  local / Cellar / go / 1.8.3 / libexec“ 
   
 
 

请注意,我是 zsh ,并且正在导出 .zshrc 文件中的> GOPATH li 可以这样:

  export GOPATH = HOME / go-workspace 
   
 
 

任何想法都值得赞赏

*更新*

根据要求,这是调用 models 包的代码段 :

  import(
“数据库/ sql” 
“日志” 
 
“ github.com/arschles/go-in-5-minutes/episode13/ 模型” 
 _“ github.com/mxk/go-sqlite/sqlite3"
)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dppxp79175
    dppxp79175 2017-07-15 16:38
    已采纳

    You can only set the gopath once and you'll have to reset it every time you change packages. Think of it as a virtualenv. One way around it is to install the packages global or by using something like gvm

    点赞 评论

相关推荐