go - 如何在 go mod 中升级 go 版本

标签 go go-modules

在 go mod 中升级 go 版本的正确方法是什么,特别是 1.13 到 1.14?
您是否只需编辑 go.mod 文件并更改 go 1.13go 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/

相关文章:

go - 如何安装特定版本的 golint 以供全局使用?

go - 如何创建一个go项目? [复制]

go - 尝试使用 go 模块在 Go 1.11 中部署 Google 云功能时出错

http - 什么是客户要求?

Golang TCP 服务器 - 在客户端之间交换数据

travis-ci 中的 go.mod 变化

go - 我想从 Goproxy 中删除我的私有(private)包

Golang : Read ints from stdin until EOF while reporting format errors

go - 为什么追加修改传递的 slice

go - 如何在 golang 中使用 klog 级别的详细信息?