How to upgrade the go version in a go mod

Command go: Edit go.mod from tools or scripts:

Usage:

go mod edit [editing flags] [go.mod]

Edit provides a command-line interface for editing go.mod, for use primarily by tools or scripts. It reads only go.mod; it does not look up information about the modules involved. By default, edit reads and writes the go.mod file of the main module, but a different target file can be specified after the editing flags.

The -go=version flag sets the expected Go language version.

So simply:

go mod edit -go=1.14

But you may also edit go.mod manually, it’s a simple text file. go mod edit is primilary for scripts so making changes to go.mod can easily be automated.

Leave a Comment