- Download Go: https://golang.org/dl/
- Create a
go
folder in local machine, in this case~/go
Note: all the go code should be inside this
go
folder
- 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.go
in~/go/src/hello/
with the following code
package main
import "fmt"
func main() {
fmt.Println("ok")
}
- Then
go run hello.go
ok