Mac下搭建go語言開發環境

來源:互聯網
上載者:User

標籤:

一.下載安裝go

到牆內下載go的安裝包:

http://www.golangtc.com/download

點擊安裝包然後進行安裝

二.配置

1.查看環境

 go version

2.安裝完sdk之後接下來便是配置環境變數了,開啟終端輸入cd ~ 進入使用者主目錄,之後輸入ls -all命令查看是否存在.bash_profile

檔案,存在既使用vim .bash_profile開啟並編輯該檔案。根據自己實際情況,內容如下:

export GOPATH=/Users/apple/Documents/dev/goexport GOBIN=$GOPATH/binexport PATH=$PATH:$GOBIN

go env

GOARCH="386"GOBIN="/Users/apple/Documents/dev/go/bin"GOCHAR="8"GOEXE=""GOHOSTARCH="386"GOHOSTOS="darwin"GOOS="darwin"GOPATH="/Users/apple/Documents/dev/go"GORACE=""GOROOT="/usr/local/go"GOTOOLDIR="/usr/local/go/pkg/tool/darwin_386"CC="gcc"GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0 -fno-common"CXX="g++"CGO_ENABLED="1"

cd /Users/apple/Documents/dev/go 

vim main.go

package mainimport (  "fmt")func main() {  fmt.Println("hello go");}

使用go build xx(項目名稱)對其進行編譯

adeMacBook-Pro:go apple$ ./mainhello go

 

Mac下搭建go語言開發環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.