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 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳