
本指南是我在 mac 机器上安装 golang 时所做的。
您使用以下内容:
来自 asdf-golang
asdf plugin add golang https://github.com/asdf-community/asdf-golang.git # install latest golang version asdf install golang latest # set the glboal version for golang to latest asdf global golang latest # reshim asdf reshim golang
goroot 是指定 go 安装位置的环境变量
将以下内容添加到~/.zshrc
. ~/.asdf/plugins/golang/set-env.zsh
这将确保每次运行终端时都设置 goroot 和 gopath
电子手机配件网站源码是一个响应式的织梦网站模板,软件兼容主流浏览器,且可以在PC端和手机端中进行浏览。模板包含安装说明,并包含测试数据。本模板基于DEDECms 5.7 UTF-8设计,需要GBK版本的请自己转换。模板安装方法:1、下载最新的织梦dedecms5.7 UTF-8版本。2、解压下载的织梦安装包,得到docs和uploads两个文件夹,请将uploads里面的所有文件和文件夹上传到你的
0
立即学习“go语言免费学习笔记(深入)”;
你可以看看 set-env.zsh 做了什么:
$ cat ~/.asdf/plugins/golang/set-env.zsh
asdf_update_golang_env() {
local go_bin_path
go_bin_path="$(asdf which go 2>/dev/null)"
if [[ -n "${go_bin_path}" ]]; then
export goroot
goroot="$(dirname "$(dirname "${go_bin_path:a}")")"
export gopath
gopath="$(dirname "${goroot:a}")/packages"
fi
}
autoload -u add-zsh-hook
add-zsh-hook precmd asdf_update_golang_env
更新当前打开的终端以使用最新的 ~/.zshrc
source ~/.zshrc
检查 goroot 和 gopath 是否设置
> echo $GOROOT /Users/username/.asdf/installs/golang/1.22.5/go > echo $GOPATH /Users/username/.asdf/installs/golang/1.22.5/packages
以上就是在 MacOS 上安装 Golang的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号