Permalink
Newer
100644
59 lines (43 sloc)
1.66 KB
8
9
If `go` is not installed, follow instructions on [the Go website](https://golang.org/doc/install).
12
13
```sh
14
$ git clone https://github.com/cli/cli.git gh-cli
15
$ cd gh-cli
16
```
17
22
# installs to '/usr/local' by default; sudo may be required, or sudo -E for configured go environments
40
41
## Cross-compiling binaries for different platforms
42
43
You can use any platform with Go installed to build a binary that is intended for another platform
44
or CPU architecture. This is achieved by setting environment variables such as GOOS and GOARCH.
45
46
For example, to compile the `gh` binary for the 32-bit Raspberry Pi OS:
47
```sh
48
# on a Unix-like system:
49
$ GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 make clean bin/gh
50
```
51
```pwsh
52
# on Windows, pass environment variables as arguments to the build script:
53
> go run script\build.go clean bin\gh GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0
54
```
55
56
Run `go tool dist list` to list all supported values of GOOS/GOARCH.
57
58
Tip: to reduce the size of the resulting binary, you can use `GO_LDFLAGS="-s -w"`. This omits
59
symbol tables used for debugging. See the list of [supported linker flags](https://golang.org/cmd/link/).