没有为命令 go 设置版本

No version set for command go

我试图在 Ubuntu 机器上用 go version 检查我的 go 可执行文件的版本,但是我收到以下错误:

No version set for command go
Consider adding one of the following versions in your config file at 
golang 1.16.8
golang 1.17.1

我该如何解决这个问题?我之前没有使用配置文件的经验,我在 google 上进行了搜索,但没有找到任何可以解决此问题的方法。

这似乎是来自 asdf-vm/asdf 的错误消息,该工具使用单个 CLI 工具管理多个运行时版本,可通过插件扩展。
您可以在 asdf-vm/asdf issue 838.

中看到该错误消息

config file应该在$HOME/.tool-versions

要解决这个问题,如 this example:

asdf plugin add go
asdf install go latest