- Download Go: https://golang.org/dl/
- Create a
gofolder in local machine, in this case~/go
Note: all the go code should be inside this
gofolder
- Set your GOPATH
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
echo "export GOPATH=$HOME/go" >> .bash_profile
- Check if install & setup successfully
- Create
hello.goin~/go/src/hello/with the following code
package main
import "fmt"
func main() {
fmt.Println("ok")
}
- Then
go run hello.go
ok