> For the complete documentation index, see [llms.txt](https://strctr.gitbook.io/programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://strctr.gitbook.io/programming/01-languages/go-lang/01-development/build.md).

# Build

Компиляция кода под конкретную платформу:

* Установить `GOOS`, `GOARCH`
* Добавить суффикс файла:
  * `file_GOARH.go`,&#x20;
  * `file_GOOS.go`
  * `file_GOOS_GOARCH.go`
* добавить file tag `// +build os1[,arch1] [!os2[,arch2]]`

![](https://1356653101-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5bu9Zoywb01ca-XJjd%2F-MXcAgzrPjHea4BzQ8u7%2F-MXcAlrSGd_k7HLP0NDX%2FScreenshot%202021-04-06%20at%2019.15.58.png?alt=media\&token=632e3b19-1aac-415c-a020-3cd4314b70c7)

Пример:

```go
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/news-backend main.go
```
