You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building:
/tmp/go/src/app$ go build main.go
../shared/toml/toml.go:4:9: cannot find package "github.com/BurntSushi/toml" in any of:
/usr/lib/go/src/github.com/BurntSushi/toml (from $GOROOT)
/tmp/go/src/github.com/BurntSushi/toml (from $GOPATH)
vendor/ directory contains needed package.
main.go imports "shared/toml" package which in turn uses the needed vendored package.
The only way to build main.go is by copying the same "vendor" dependency inside shared/toml/ which seems overkill and duplication.
Does the compiler ignore the vendor directory? I.e. some sort of "lexical" scope since the parsed file at the moment (shared/toml) don't have a sub-directory vendor, but the initial compilation process starts from main.go.
If that is a current limitation and not my misuse, then that means if I want to have a complete insulation from "system" $GOPATH (and use my own) and keep all dependencies (normally collected with "go dep" / dep ensure) means I have to copy that vendor directory to all $GOPATH/src/modules
What did you expect to see?
Using the vendor path for building the app and imported packages inside $GOPATH
What did you see instead?
Missing package, already available in the vendor directory
/tmp/go/src/app$ go build main.go
../shared/toml/toml.go:4:9: cannot find package "github.com/BurntSushi/toml" in any of:
/usr/lib/go/src/github.com/BurntSushi/toml (from $GOROOT)
/tmp/go/src/github.com/BurntSushi/toml (from $GOPATH)
The text was updated successfully, but these errors were encountered:
Code below a directory named "vendor" is importable only by code in the directory tree rooted at the parent of "vendor", and only using an import path that omits the prefix up to and including the vendor element.
In this case shared/toml/toml.go is trying to import github.com/BurntSushi/toml, but that directory is only available in app/vendor, not in shared/vendor.
I have "shared" contract/interface package(s) and go applications that are using them.
Since I want to vendor my app1, I have a vendor directory inside site.org/app1, however to build app1 executable I also need to have vendor, which contains the same packages (github.com/golang/protobuf).
So, the expected behavior is to do "dep init" and "dep ensure" in each of the packages, right?
We use the issue tracker for bugs and proposals, not discussion. Let's take questions to the mailing list, where you find better answers anyhow. See https://golang.org/wiki/Questions . Thanks.
What version of Go are you using (
go version
)?go version go1.9.1 linux/amd64
What did you do?
gopath.tar.gz
I have the following structure:
/tmp/go/src/app$ tree -L 3 ../
$ echo $GOPATH
/tmp/go
When building:
/tmp/go/src/app$ go build main.go
../shared/toml/toml.go:4:9: cannot find package "github.com/BurntSushi/toml" in any of:
/usr/lib/go/src/github.com/BurntSushi/toml (from $GOROOT)
/tmp/go/src/github.com/BurntSushi/toml (from $GOPATH)
vendor/ directory contains needed package.
main.go imports "shared/toml" package which in turn uses the needed vendored package.
The only way to build main.go is by copying the same "vendor" dependency inside shared/toml/ which seems overkill and duplication.
Does the compiler ignore the vendor directory? I.e. some sort of "lexical" scope since the parsed file at the moment (shared/toml) don't have a sub-directory vendor, but the initial compilation process starts from main.go.
If that is a current limitation and not my misuse, then that means if I want to have a complete insulation from "system" $GOPATH (and use my own) and keep all dependencies (normally collected with "go dep" / dep ensure) means I have to copy that vendor directory to all $GOPATH/src/modules
What did you expect to see?
Using the vendor path for building the app and imported packages inside $GOPATH
What did you see instead?
Missing package, already available in the vendor directory
/tmp/go/src/app$ go build main.go
../shared/toml/toml.go:4:9: cannot find package "github.com/BurntSushi/toml" in any of:
/usr/lib/go/src/github.com/BurntSushi/toml (from $GOROOT)
/tmp/go/src/github.com/BurntSushi/toml (from $GOPATH)
The text was updated successfully, but these errors were encountered: