go module dependencies management

The greatest advantage is to go mod GOPATH out of this restriction, in addition to GOPATH directory can also carry out your project

go mod use:

1. Make sure you go over version 1.1

2. Create a project directory example, go and add a file

3, open a command line to switch to that directory.

4, set the environment variable, SET GO111MODULE = on that you want to work in a directory other than GOPATH.

5, go mod init example file created mod.go

6, go tidy download the required dependencies, delete unnecessary dependencies. (If you need to download the wall of the package, you can SET GOPROXY = https: //goproxy.cn)

If it can not be modified mod.go file access golang.org

Replace (
golang.org/x/crypto => Latest github.com/golang/crypto
)
or use the command
go mod edit -replace = golang.org / x / crypto @ v0.0.0 = github.com / golang / crypto @ latest

Guess you like

Origin www.cnblogs.com/tigerzhouv587/p/11388740.html