This is a creation in
Article, where the information may have evolved or changed.
The Go language supports the following systems:
- Linux
- Freebsd
- Mac OS X (also known as Darwin)
- Window
The download address for the installation package is: https://golang.org/dl/.
Installation:
Download: go1.3.darwin-amd64-osx10.8.pkg
Default installation, the/usr/local/go directory is installed
and set the environment variable.
Go env to view the current environment variables for Go
Configuration:
According to the Convention, 3 directories need to be established under Gopath:
-
Bin stores the compiled executable file
-
Pkg to store package files generated after compilation
-
SRC Store The source code of the project
I built Gopath on/users/apple/documents/gowork.
cd ~open .bash_profile加入:export GOPATH=/Users/zhaorai/Desktop/gowork
Gowork directory:
To take effect immediately please run:
source ~/.bash_profile
Test examples:
//hello.go package mainimport"fmt"//实现格式化的I/O /*Printf someting*/func main(){ fmt.Printf("Hello,World!\n") }
In terminal execution:
bo build helloworld.gobo run helloworld.go
Execution Result:
Hello,World!