Skip to content
Permalink
Newer
Older
100644 59 lines (43 sloc) 1.66 KB
3
1. Verify that you have Go 1.18+ installed
Jun 1, 2020
8
9
If `go` is not installed, follow instructions on [the Go website](https://golang.org/doc/install).
10
12
13
```sh
14
$ git clone https://github.com/cli/cli.git gh-cli
15
$ cd gh-cli
16
```
17
20
#### Unix-like systems
21
```sh
22
# installs to '/usr/local' by default; sudo may be required, or sudo -E for configured go environments
23
$ make install
25
# or, install to a different location
26
$ make install prefix=/path/to/gh
29
#### Windows
31
# build the `bin\gh.exe` binary
32
> go run script\build.go
34
There is no install step available on Windows.
36
4. Run `gh version` to check if it worked.
37
38
#### Windows
39
Run `bin\gh version` to check if it worked.
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/).