This is a creation in Article, where the information may have evolved or changed.
Processor Architecture $GOARCH Target platform (compiled target platform) (386, AMD64, ARM)
Operating system $GOOS target platform (compiled target platform) (Darwin, FreeBSD, Linux, Windows)
GOOS and Goarch reference for each platform
OS ARCH OS Version
Linux 386 / amd64 / arm >= Linux 2.6
Darwin 386 / amd64 OS X (Snow Leopard + Lion)
FreeBSD 386 / amd64 >= FreeBSD 7
Windows 386 / amd64 >= windows
1. Current system:
FUYUNDEMACBOOK-PRO:SRC fuyun$ uname-a
Darwin fuyundemacbook-pro.local 13.2.0 Darwin Kernel Version 13.2.0:thu Apr 23:03:13 PDT 2014; Root:xnu-2422.100.13~1/release_x86_64 x86_64
2. Download and install GO1.3
- Go1.3.darwin-amd64-osx10.8.pkg
Execute the following command:
$ cd/usr/local/go/src
$ sudo cgo_enabled=0 goos=linux goarch=amd64./make.bash
Here is an additional environment variable cgo_enabled because cross-compilation does not support CGO, we disable it here.
This is not to recompile go, because when you install go, you just compile what your local system needs, and cross-platform compilation requires more support for other platforms in go. So, there is./make.bash such a process.
The execution results are similar to the following:
Fuyundemacbook-pro:pkg fuyun$ CD/USR/LOCAL/GO/SRC
Fuyundemacbook-pro:src fuyun$ sudo cgo_enabled=0 goos=linux goarch=amd64./make.bash
Password:
# Building C Bootstrap tool.
Cmd/dist
# Building compilers and Go bootstrap tool for host, Darwin/amd64.
Lib9
Libbio
Liblink
Misc/pprof
cmd/cc
Cmd/gc
cmd/6l
cmd/6a
cmd/6c
cmd/6g
Pkg/runtime
Pkg/errors
Pkg/sync/atomic
Pkg/sync
Pkg/io
Pkg/unicode
Pkg/unicode/utf8
Pkg/unicode/utf16
Pkg/bytes
Pkg/math
Pkg/strings
Pkg/strconv
Pkg/bufio
Pkg/sort
Pkg/container/heap
Pkg/encoding/base64
Pkg/syscall
Pkg/time
Pkg/os
Pkg/reflect
Pkg/fmt
Pkg/encoding
Pkg/encoding/json
Pkg/flag
Pkg/path/filepath
Pkg/path
Pkg/io/ioutil
Pkg/log
Pkg/regexp/syntax
Pkg/regexp
Pkg/go/token
Pkg/go/scanner
Pkg/go/ast
Pkg/go/parser
Pkg/os/exec
Pkg/os/signal
Pkg/net/url
Pkg/text/template/parse
Pkg/text/template
Pkg/go/doc
Pkg/go/build
Cmd/go
Pkg/runtime (LINUX/AMD64)
# Building packages and commands for host, Darwin/amd64.
Runtime
Errors
Sync/atomic
Unicode
Unicode/utf8
Math
Sync
Sort
Container/heap
Io
Syscall
Hash
Encoding
Unicode/utf16
Hash/crc32
Container/list
Crypto/subtle
bytes
Strings
Bufio
Text/tabwriter
Path
Crypto/cipher
Time
Crypto/hmac
Compress/bzip2
Hash/adler32
Container/ring
Hash/crc64
Hash/fnv
Html
Image/color
Image/color/palette
StrConv
Math/rand
Math/cmplx
Os
Runtime/race
Reflect
Crypto
Encoding/base64
Crypto/md5
Regexp/syntax
Net/url
Crypto/aes
Path/filepath
Crypto/rc4
Io/ioutil
Os/exec
Crypto/sha1
Regexp
crypto/sha256
crypto/sha512
Encoding/pem
Net
Os/signal
Encoding/ascii85
Encoding/binary
Fmt
Encoding/base32
Crypto/des
Image
Index/suffixarray
Image/draw
Image/jpeg
Debug/dwarf
Debug/gosym
Debug/plan9obj
Flag
Log
Debug/elf
Debug/macho
Debug/pe
Go/token
Encoding/json
Go/scanner
Go/ast
Cmd/addr2line
Encoding/xml
Text/template/parse
Go/parser
Go/printer
Text/template
Compress/flate
Math/big
Compress/gzip
Go/doc
Encoding/hex
Mime
Cmd/cgo
Go/format
Cmd/fix
Crypto/elliptic
Go/build
Crypto/ecdsa
Crypto/rand
Crypto/rsa
Crypto/dsa
Encoding/asn1
Net/textproto
Mime/multipart
Crypto/x509/pkix
crypto/x509
Runtime/pprof
Cmd/gofmt
Cmd/nm
Crypto/tls
Cmd/objdump
Cmd/pack
Cmd/yacc
Net/http
Archive/tar
Archive/zip
Compress/lzw
Compress/zlib
Database/sql/driver
Encoding/csv
Database/sql
Encoding/gob
Html/template
Cmd/go
Expvar
Image/gif
Image/png
Log/syslog
net/http/cgi
Net/http/cookiejar
Net/http/httptest
Net/http/httputil
net/http/fcgi
Net/http/pprof
Net/mail
Net/rpc
Net/smtp
Os/user
Runtime/debug
Testing
Testing/iotest
Net/rpc/jsonrpc
Testing/quick
Text/scanner
# Building packages and commands for LINUX/AMD64.
Runtime
Errors
Sync/atomic
Unicode
Unicode/utf8
Math
Sync
Sort
Io
Syscall
Hash
Container/heap
Encoding
Unicode/utf16
bytes
Strings
Bufio
Text/tabwriter
Path
Hash/crc32
Container/list
Crypto/subtle
Time
Crypto/cipher
Crypto/hmac
Compress/bzip2
Hash/adler32
Container/ring
Hash/crc64
Hash/fnv
Html
Image/color
StrConv
Math/rand
Image/color/palette
Os
Math/cmplx
Reflect
Crypto
Crypto/md5
Encoding/base64
Regexp/syntax
Net/url
Path/filepath
Crypto/aes
Crypto/rc4
Io/ioutil
Os/exec
Crypto/sha1
crypto/sha256
Regexp
crypto/sha512
Encoding/pem
Encoding/binary
Fmt
Net
Crypto/des
Os/signal
Encoding/ascii85
Encoding/base32
Image
Index/suffixarray
Runtime/race
Debug/dwarf
Debug/gosym
Debug/plan9obj
Flag
Log
Go/token
Encoding/json
Debug/elf
Debug/macho
Debug/pe
Go/scanner
Cmd/addr2line
Encoding/xml
Go/ast
Text/template/parse
Go/parser
Go/printer
Compress/flate
Text/template
Compress/gzip
Math/big
Encoding/hex
Mime
Cmd/cgo
Go/format
Cmd/fix
Go/doc
Crypto/elliptic
Crypto/ecdsa
Go/build
Crypto/rand
Crypto/rsa
Crypto/dsa
Encoding/asn1
Net/textproto
Mime/multipart
Crypto/x509/pkix
Runtime/pprof
crypto/x509
Cmd/nm
Cmd/gofmt
Crypto/tls
Cmd/objdump
Cmd/pack
Cmd/yacc
Net/http
Archive/tar
Archive/zip
Compress/lzw
Compress/zlib
Database/sql/driver
Database/sql
Encoding/csv
Encoding/gob
Html/template
Image/draw
Image/gif
Cmd/go
Expvar
Image/jpeg
Image/png
Log/syslog
net/http/cgi
Net/http/cookiejar
Net/http/httptest
net/http/fcgi
Net/http/httputil
Net/http/pprof
Net/mail
Net/rpc
Net/smtp
Os/user
Runtime/debug
Testing
Testing/iotest
Net/rpc/jsonrpc
Testing/quick
Text/scanner
---
Installed Go for LINUX/AMD64 In/usr/local/go
Installed Commands In/usr/local/go/bin
FUYUNDEMACBOOK-PRO:SRC fuyun$
The post-compilation bin directory is more linux_amd64 required tools
Fuyundemacbook-pro:bin fuyun$ pwd
/usr/local/go/bin
Fuyundemacbook-pro:bin fuyun$ ls
Go godoc gofmt linux_amd64 windows_amd64
3, to the source code directory execution:
Cgo_enabled=0 goos=linux goarch=amd64 Go Build
Go build without the preceding parameters simply compiles the executable file that the development environment applies to.
Note: Refer to network data + experiment.