Learning Path: The basics of Go programming without a sniff
Mac installation Golang
Two installation methods are introduced, and can also be installed by brew.
PKG Installation
Download Address
The next step is to install
Tar Package Decompression Installation
Download Address
-C /usr/local-xzf go$VERSION.$OS-$ARCH.tar.gz
Unzip to install
Brew Installation
Tutorial
install go
Path settings
Take the brew installation go as an example.
export PATH=$PATH:/usr/local/opt/go/libexec/binexport GOROOT=/usr/local/opt/go/libexecexport GOPATH=$HOME/.goexport PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Before joining. Zshrc,source ~/.ZSHRC Make it effective
Note: Export path= $PATH:/usr/local/opt/go/libexec/bin Not set is also possible, because there are links in/usr/local/bin.
Test
New file
vim hello.go
Input code
package mainimport"fmt"func main(){ fmt.Printf("Hello, go!")}
Test run
go run hello.go
Output results
Hellogo!%