The new package management ideas Go 1.11 raised to support Go look at a program in a modular fashion, with go.mod version management information, the basic fact is automatically generated
1. Basic Operation
Empty file generated go.mod
go mod init <your module path>
Automatically fill dependence, generate go.sum, since this mainly to record once used to do a recording with a version of hash
go build
After the change, and view the current version relies ===> need to go build (?
List -m All Go
Go List -m -version 'may be a link on git' // View a past version number
If you need to manually modify, use the following command line
go mod edit -replace 'module name'
Rollback Versions:
GET Go github.com/gin-gonic/[email protected] get the previous version, this version is rolled back. .
Edit -require = MOD Go "github.com/gin-gonic/[email protected]" + Go Tidy change dependent on the version number, and download the corresponding package. .
updated version:
go get -u
《?
2. Other commands
go mod tidy
All the Dependencies that you at The FETCH need for Testing in your Module , will remove unwanted dependencies
go mod why -m <module>
find out where any of your dependencies are used
go mod vendor
Generate vendor directory
3. Acting
1.1's new environment variable, as mirrored in the code repository proxy golang
How to configure:
Configuration environment variable GOPROXY = HTTPS Export: // . . . .
After the proxy fails, will not automatically back to the source, so you can use goc tool,
Available Agent:
gocenter.io
goproxy.io