Open deoren opened 5 years ago
Example tree
structure for the vendor folder in the golang-book-examples/hour13/example02
path:
$ tree
.
|-- example02.go
`-- vendor
`-- github.com
`-- golang
`-- example
`-- stringutil
|-- reverse.go
`-- reverse_test.go
5 directories, 3 files
As an example, the Go in 24 Hours book has this import block:
and a
vendor
subfolder with a copy of the package (one relative and one explicit here for illustration):./vendor/github.com/golang/example/stringutil
$GOPATH/src/github.com/shapeshed/golang-book-examples/tree/master/hour13/example02/vendor/github.com/golang/example/stringutil
Because the
vendor
directory is present and we're using a recent Go verion (e.g., v1.12), Go will use the code from thevendor
directory instead of code from$GOPATH/src/github.com/golang/example/stringutil
.