当前位置:网站首页>This new change of go 1.16 needs to be adapted: the changes of go get and go install

This new change of go 1.16 needs to be adapted: the changes of go get and go install

2022-06-26 09:46:00 wohu1104

Original address :
Go 1.16 This new change needs to be adapted :go get and go install The change of

all the time ,go get For downloading and installing Go package 、 Orders, etc , and go install stay module It is rarely used in the times , stay GOPATH years ,go install Used to compile and install local projects .

since 1.16 rise , The official said , Should not be go get Download the installation command ( You can execute the program ), But it's just that , But it can still be used .

but Go1.17 Start , If you use go get Installation command , Warning :

$ go get github.com/github/hub
go get: installing executables with 'go get' in module mode is deprecated.
 To adjust and download dependencies of the current module, use 'go get -d'.
 To install using requirements of the current module, use 'go install'.
 To install ignoring the current module, use 'go install' with a version,
 like 'go install example.com/[email protected]'.
 For more information, see https://golang.org/doc/go-get-install-deprecation
 or run 'go help get' or 'go help install'.

in other words ,go get Only for downloading ordinary packages , Install executable , You should use go install.

$ go install github.com/github/hub

This will hub Command to install to $GOBIN Next .

Besides ,go get There is a parameter -d, instructions go get Download the corresponding package , But do not compile and install . Future versions ,-d Will become the default behavior , It will be faster . Besides , Because it doesn't compile , Even if the target relies on compiling an error on a specific platform ,go get It can also be executed normally .

About Go 1.16 The change of .Reddit There is a picture on the drawing that summarizes very well :
 change

原网站

版权声明
本文为[wohu1104]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170549209989.html