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

在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"
)
  • 写回答

1条回答 默认 最新

  • 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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了