在 go mod 中升级 go 版本的正确方法是什么,特别是 1.13 到 1.14?
您是否只需编辑 go.mod 文件并更改 go 1.13
至 go 1.14
?
我不是在问如何编辑 go.mod 文件,我是在问简单地更改 go.mod 文件中的 go 版本是否合适,并且其他所有内容(所有依赖项)对于该项目仍然没问题?
最佳答案
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.
很简单:
go mod edit -go=1.14
但您也可以编辑 go.mod
手动,它是一个简单的文本文件。 go mod edit
主要用于脚本,因此对 go.mod
进行更改可以很容易地实现自动化。
关于go - 如何在 go mod 中升级 go 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60675415/