├── README.md ├── go_build.sh └── install.sh /README.md: -------------------------------------------------------------------------------- 1 | # go_build for Go-lang cross-platform build script 2 | 3 | ### How to install 4 | ``` 5 | curl -sL bit.ly/go_build_install |bash 6 | ``` 7 | 8 | ### How to use 9 | ``` 10 | go_build.sh [Package-name] 11 | ``` 12 | 13 | ### Sample 14 | [![asciicast](https://asciinema.org/a/b9tv4cubs13zd68vxrp2gr39k.png)](https://asciinema.org/a/b9tv4cubs13zd68vxrp2gr39k?autoplay=1&speed=2) 15 | 16 | -------------------------------------------------------------------------------- /go_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### Code from https://github.com/ralfyang/go_build. Powered by Github. 3 | 4 | Package_name=$1 5 | BARR="#################################################################" 6 | Name=(windows MacOS freebsd RHEL/Ubuntu/Fedora/Suse openbsd netbsd dragonfly plan9) 7 | OS=(windows darwin freebsd linux openbsd netbsd dragonfly plan9) 8 | ARCH=(32bit 64bit) 9 | 10 | echo "" 11 | echo "$BARR" 12 | echo " Please select OS as below list" 13 | echo "$BARR" 14 | Count=0 15 | while [ $Count -lt ${#Name[@]} ];do 16 | echo "[`expr $Count + 1`] - ${Name[$Count]}" 17 | 18 | let Count=$Count+1 19 | done 20 | echo "$BARR" 21 | echo " Select a number: [ 1 - ${#Name[@]} ]" 22 | read OS_choose 23 | 24 | Chose_OS=${OS[$OS_choose-1]} 25 | 26 | echo "$BARR" 27 | echo "[1] ${ARCH[0]}, [2] ${ARCH[1]}: [ 1 - 2 ]" 28 | read Bit_choose 29 | if [[ $Bit_choose = "1" ]];then 30 | Chose_Bit="386" 31 | elif [[ $Bit_choose = "2" ]];then 32 | Chose_Bit="amd64" 33 | fi 34 | 35 | 36 | export GOOS=$Chose_OS 37 | export GOARCH=$Chose_Bit 38 | go build -v $Package_name 39 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | curl -sL https://github.com/goody80/go_build/raw/master/go_build.sh > ~/go_build.sh 3 | if [[ `(which sudo 2> /dev/null)` = "" ]];then 4 | SUDO="" 5 | else 6 | SUDO="sudo" 7 | fi 8 | 9 | $SUDO cp ~/go_build.sh /usr/bin/go_build.sh 10 | $SUDO chmod 755 /usr/bin/go_build.sh 11 | 12 | --------------------------------------------------------------------------------