Deprecation of go get in golang 1.17.1

Ankit Kumar
2 min readSep 21, 2021

As golang released their new version 1.17.1 and you might get this error while installing packages using go get -u.

e.g I tried to install the goose package using:

$ go get -u github.com/pressly/goose/v3/cmd/goose

Error returned:

go get: installing executables with ‘go get’ in module mode is deprecated.
Use ‘go install pkg@version’ instead.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run ‘go help get’ or ‘go help install’.

Why go get is deprecated?

The go gethas been used both to update dependencies in go.mod and to install commands. This combination is confusing and inconvenient to use, as developers don’t want both updates and installation at the same time.

As golang released their new version 1.17.1 and go get is not supported anymore.

So how to install the packages then? 💭

  1. According to the documentation, To install an executable in the context of the current module, use, go install without a version suffix, as below. This applies version requirements and other directives from the go.mod file in the current directory or a parent directory. e.g.
go install example.com/cmd

2. To install an executable while ignoring the current module, use go install with a version suffix like @v1.2.3 or @latest

So the changes are: replace get with install, remove -u add @latest to the end of the package URL.

OR

Add manual version at the end of package URL for older versions instead of latest.

Now it will install successfully. Thank You 😄

References:

https://golang.org/doc/go-get-install-deprecation

--

--