deoren / notes

Various notes for topics I'm learning
2 stars 0 forks source link

Golang | vendor folder #68

Open deoren opened 5 years ago

deoren commented 5 years ago

As an example, the Go in 24 Hours book has this import block:

import (
    "fmt"
    "github.com/golang/example/stringutil"
)

and a vendor subfolder with a copy of the package (one relative and one explicit here for illustration):

Because the vendor directory is present and we're using a recent Go verion (e.g., v1.12), Go will use the code from the vendor directory instead of code from $GOPATH/src/github.com/golang/example/stringutil.

deoren commented 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