32

如何在Mac搭建golang环境

 5 years ago
source link: https://studygolang.com/articles/16143?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

最近学一下go语言,需要在Mac上搭建go的开发环境。

我比较喜欢用zsh命令行工具,我就从装zsh说起吧

$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

启用zsh:

$zsh

安装go的话,去官网看就行了,很详细。 https://studygolang.com/dl

安装完成后,添加go的PATH环境变量

指定开发文件,设置GOPATH

编辑.zshrc

vim ~/.zshrc

主要内容是这样的

export GOPATH=~/desktop/gopath
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.2:/usr/kde/3.5/sbin:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/local/go/bin:~/desktop/gopath/bin

如果zsh安装后不能正常使用,则执行一下下面的这条命令,可以临时恢复正常,注意:是临时。可以把它加到.zshrc中,就可以永久正常。

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.2:/usr/kde/3.5/sbin:/usr/kde/3.5/bin:/usr/qt/3/bin"

如果还有什么问题,欢迎留言哦


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK