Reputation: 4960
I'm in the process of relearning Go. I installed the latest Go version (1.7.1
) using gvm and I am looking to build a simple rest api app using gin. I installed it using glide get https://github.com/gin-gonic/gin
(glide) and that created a "vendor" folder on my project root. Running my app though, go run main.go
, I encounter this error
main.go:3:8: cannot find package "github.com/gin-gonic/gin" in any of:
/home/yowmamasita/.gvm/gos/go1.6.3/src/github.com/gin-gonic/gin (from $GOROOT)
/home/yowmamasita/.gvm/pkgsets/go1.6.3/global/src/github.com/gin-gonic/gin (from $GOPATH)
It is not resolving the "vendor" directory glide just created
.
├── glide.lock
├── glide.yaml
├── main.go
├── README.md
└── vendor
└── github.com
└── gin-gonic
└── gin
Not sure what's happening here, I thought after 1.5, it should be able to resolve imports from "vendor" directories without doing anything. I even added my projects folder on my $GOPATH
/home/yowmamasita/.gvm/pkgsets/go1.7.1/global:/home/yowmamasita/goprojects
What am I doing wrong here? I tried 1.6.3 too and I get the same error.
Upvotes: 1
Views: 2871
Reputation: 6444
Please make sure:
/home/yowmamasita/goprojects
) to $GOPATH
variable. bin
, pkg
and src
. More detailspkg
and bin
, but the project which is using vendor
packages or your custom package must be placed under $GOPATH/src
, otherwise go
compiler will not recognized it. More discussions can be found here and here
The structure should look like:
$GOPATH
└── src
└── YOURPROJECT1
├── source codes #1
└── vendor/
└── YOURPROJECT2
├── source codes #2
└── vendor/
Upvotes: 2