简体   繁体   中英

How make go import packages from vendor?

I was checking the vendor feature in go with glide. It was awesome installing all packages but I couldn't manage to make go command to found them in the vendor packages.

go run src/main.go

src/main.go:8:2: cannot find package "github.com/valyala/fasthttp" in any of:
   /home/joaonrb/.software/lib/go/go1.7/src/github.com/valyala/fasthttp (from $GOROOT)
   /home/joaonrb/.projects/go-blog/src/github.com/valyala/fasthttp (from $GOPATH)

Fasthttp is installed in /home/joaonrb/.projects/go-blog/src/vendor/github.com/valyala/fasthttp , the version of go I'm using is 1.7 and my GOPATH is /home/joaonrb/.projects/go-blog

Your GOPATH structure does not seem valid. To do what you want:

  • Create a "project" folder, eg $GOPATH/src/myproj .
  • Put your main.go there.
  • Create a vendor folder there, eg $GOPATH/src/myproj/vendor .
  • Put github.com/valyala/fasthttp there.

That should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM