差異處
這裏顯示兩個版本的差異處。
| 下次修改 | 前次修改 | ||
|
go [2016/08/17 12:41] jz 建立 |
go [2016/12/04 23:16] (目前版本) jz |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | Cross compile | + | ====== Cross compile ====== |
| - | From linux to windows | ||
| + | ===== From linux to windows ===== | ||
| + | |||
| + | Make sure the toolchain for windows is installed. | ||
| + | |||
| + | <code bash> | ||
| sudo pacman -S mingw-w64-gcc | sudo pacman -S mingw-w64-gcc | ||
| + | </code> | ||
| - | 32bit | + | |
| + | **32bit** | ||
| <code bash> | <code bash> | ||
| CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -o gorvp.exe main.go | CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -o gorvp.exe main.go | ||
| </code> | </code> | ||
| - | 64bit | + | **64bit** |
| <code bash> | <code bash> | ||
| CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -o gorvp.exe main.go | CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -o gorvp.exe main.go | ||
| + | </code> | ||
| + | |||
| + | ====== Install GO on CentOS ====== | ||
| + | |||
| + | ===== Binary ===== | ||
| + | |||
| + | <code bash> | ||
| + | wget https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz | ||
| + | tar -zxf go1.7.3.linux-amd64.tar.gz -C /usr/local/ | ||
| + | mkdir /Golang | ||
| + | </code> | ||
| + | |||
| + | <code bash> | ||
| + | vim /etc/profile | ||
| + | export GOROOT=/usr/local/go | ||
| + | export GOBIN=$GOROOT/bin | ||
| + | export GOPKG=$GOROOT/pkg/tool/linux_amd64 | ||
| + | export GOARCH=amd64 | ||
| + | export GOOS=linux | ||
| + | export PATH=$PATH:$GOBIN:$GOPKG | ||
| + | |||
| + | vim ~/.bash_profile | ||
| + | export GOPATH=/Golang | ||
| + | export PATH=$PATH:$GOPATH/bin | ||
| + | </code> | ||
| + | |||
| + | ==== YUM ==== | ||
| + | |||
| + | <code bash> | ||
| + | yum install epel -y | ||
| + | yum install go -y | ||
| + | |||
| + | vim ~/.bash_profile | ||
| + | export GOPATH=$HOME/go | ||
| + | export PATH=$PATH:$GOPATH/bin | ||
| </code> | </code> | ||
