This is a creation in Article, where the information may have evolved or changed.
1. Download go
Website download address (need to turn over the wall)
Golang
China Mirror website Download
Golangtc
Download the go1.5.1.darwin-amd64.tar.gz package, unzip to get a go directory, move the go directory to the path you want, I'm here to put it ~/Documents/go
under this path
2. Configure Environment variables
Open the terminal using vim .bash_profile
the command to open the configuration file and modify the save, add the following statement
#GOPATH export GOPATH=~/Applications/Go #GOROOT export GOROOT=~/Documents/go #PATH export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
GOROOT
The variable is the path to the downloaded go directory, which GOPATH
must be set, and not the same as the Go directory, which is GOROOT
used to store the go source, go executable files, and the corresponding compiled package files. So there are three subdirectories under this directory: src, bin, pkg. Here I ~/Applications/
create a new Go
directory, and in the Go
directory of the new SCR, bin, pkg three directory.
More in-depth understanding of GO environment variables or learning can read the book below
Build-web-application-with-golang
Configuration complete save after exiting, run the following command to make the environment variable effective
source .bash_profile
3. Download the installation configuration Liteide
Download Address
Liteide Download
After installation open Liteide Edit the current environment, where the configuration and the previous GO environment variable configuration, in fact, the previous environment variable configuration can be ignored, here to configure
查看->编辑当前环境
Open it
Configured as follows
# native compiler drawin amd64GOROOT=$HOME/Documents/goGOPATH=$HOME/Applications/GoGOBIN=GOARCH=amd64GOOS=darwinCGO_ENABLED=1PATH=$GOROOT/bin:$GOPATH/bin:$PATHLITEIDE_GDB=/usr/local/bin/gdbLITEIDE_MAKE=makeLITEIDE_TERM=/usr/bin/openLITEIDE_TERMARGS=-a TerminalLITEIDE_EXEC=/usr/X11R6/bin/xtermLITEIDE_EXECOPT=-e
After saving the exit, the build is complete.
4.Hello World
$GOPATH/src/
under Create directory hello
use liteide Open Directory, create filemain.go
package mainimport "fmt"func main(){ fmt.Println("Hello world!")}
Click on the BR button above to run the build and run