1,brew install go;
lanyuan@lanyuans-MacBook-Pro apache-maven-3.8.4 % brew install go
Running `brew update --preinstall`...
go 1.17.2 is already installed but outdated (so it will be upgraded).
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/go-1.17.6.monterey.bottle.tar.gz
curl: (22) The requested URL returned error: 404
Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/go/manifests/1.17.6
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/go/blobs/sha256:c81555a115fbd99ab1c74e9b3e1d056864c31a4274803381230984f4a70fdf63
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c81555a115fbd99ab1c74e9b3e1d056864c31a4274803381230984f4a70fdf63?se
######################################################################## 100.0%
==> Upgrading go
1.17.2 -> 1.17.6
==> Pouring go--1.17.6.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/go/1.17.6: 10,826 files, 565.9MB
==> Running `brew cleanup go`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/go/1.17.2... (10,814 files, 565.8MB)
安装确认:go env
2,测试例子:
vi app.go
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
:wq退出;
go build
./helloworld
如果环境有问题,检查go env。