1

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"
)
thitami
  • 828
  • 2
  • 21
  • 44
  • Is the package at any of those locations? I'm not familiar with glide but it sounds like you need to run `go get` first. – Corey Ogburn Jul 13 '17 at 15:21
  • No, that is the issue. The package is not there. Glide is a vendor package manager, such as composer for PHP. – thitami Jul 13 '17 at 15:32
  • What command are you running when glide gives you that error? – Corey Ogburn Jul 13 '17 at 15:33
  • `glide install`, which installs all the dependencies. `go get` did the job but I am wondering whether the message thrown indicated that there is false setup in my machine. – thitami Jul 13 '17 at 15:35
  • 1
    Hi, can you share your code? It looks strange that your package `github.com/thitami/go-in-5-minutes/episode13/models` is looking for `github.com/arschles/go-in-5-minutes/episode13/models` – Raimondas Kazlauskas Jul 13 '17 at 16:03
  • @RaimondasKazlauskas Updated my question with the `import` – thitami Jul 13 '17 at 16:12
  • doesn't glide install the packages to the vendor folder location? That would mean you need to set your gopath to where the vender directory is..normally the top level of your project. https://github.com/Masterminds/glide – reticentroot Jul 13 '17 at 20:40
  • @reticentroot That is correct. Packages go under vendor folder. Thing is that this is a series of screencasts and respective number of "projects", so shall I be resetting the GOPATH in every case? – thitami Jul 14 '17 at 07:35
  • I see. That sheds some light @reticentroot. Many thanks! – thitami Jul 15 '17 at 15:50
  • @thitami moved this to an answer so that this question can be closed. – reticentroot Jul 15 '17 at 16:38

1 Answers1

1

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

reticentroot
  • 3,612
  • 2
  • 22
  • 39