go mod
You can make the project independent from the mandatory dependencies GOPATH out, that is no longer dependent on your project needs to be placed in GOPATH below, and each project dependencies, the current version of the project can be managed independently!
mod operation records
-
export GO111MODULE=on
-
go mod init github.com/mutex73/ga
Increased reliance can manually
go.uber.org/atomic v1.4.0
or let go automatically discover and maintain the following build will automatically find dependencies -
go build src/practice/mod/vendor_test.go
vendor_test.go document adds import "go.uber.org/zap" statement, IDE prompts an error, dependencies recorded in go.mod executed after build
module github.com/mutex73/ga go 1.12 require ( go.uber.org/atomic v1.4.0 // indirect go.uber.org/multierr v1.1.0 // indirect go.uber.org/zap v1.10.0 )
-
go mod download
Dependencies are automatically downloaded to
$GOPATH/pkg/mod
multiple projects can be shared cache mod
-
go mod vendor
Copied from mod project into
vendor
the directory, so that the IDE can be identified!