I'm using go-1.7 in MacOS Sierra.
My project is inside my $GOPATH/src folder and has a vendor folder inside with all its dependencies.
and I'm using the dependencies like this inside my code:
import (
"github.com/google/go-github/github"
)
Now if I run go build
i get the message that all my dependencies I use could not be found inside the $GOROOT and $GOPATH on the other and adding "vendor" to my code is working:
import (
"vendor/github.com/google/go-github/github"
)
But as far as I understood it should be possible to to like in the first code snipped.
ah FYI there are no symlinks etc.
Should I commit my vendor directory? It's the only way to get truly reproducible builds, as it guards against upstream renames, deletes and commit history overwrites. You don't need an extra dep ensure step to sync vendor/ with Gopkg. lock after most operations, such as go get, cloning, getting latest, merging, etc.
js land, Golang's vendor folder is basically the same as Node's node_modules . It is a folder found at the root of a module that stores a copy of all the code the module depends on. The code is used to compile the final executable when the go build command is run.
"vendor" is the folder where a Drupal - composer Installation stores it's libraries. If you look at the file web/autoload. php you'll find how that works.
If you're working on a sufficiently large project, it might make sense to you and your team to add vendor to your . gitignore . You'll just miss out on some amazing benefits of having all the code required to build your app stored in your source control, including: Reproducible builds.
From go 1.12+ go modules is the new way of handling dependencies.
go mod init
go mod vendor
go build -mod vendor -o output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With