1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 08:08:02 +00:00

Add Build For A Specific OS And Architecture as a go til

This commit is contained in:
jbranchaud
2018-03-06 21:55:06 -06:00
parent abfcfd4641
commit 0a554c50dd
2 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
# Build For A Specific OS and Architecture
Go programs can run anywhere, but you've got to create builds specific to
each operating system and architecture. This can be done when building by
specifying the `GOOS` and `GOARCH` environment variables.
For example, if you'd like to build a 32-bit Linux distribution:
```bash
GOOS=linux GOARCH=386 go build -o linux_386_build
```
The `GOOS` value specifies the operating system as Linux and the `GOARCH`
value of `386` specifies a 32-bit architecture.
The plethora of `GOOS` and `GOARCH` options can be found
[here](https://golang.org/doc/install/source#environment).