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

在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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?