User Tools

Site Tools


go:tooling:go_build

go build

What is it?

`go build` compiles Go source code into an executable binary.

What is it used for?

  • Produce a runnable file for deployment.
  • Build for specific platforms, including cross-compiling.

Examples

  • Build with the default output name:
    go build .
 
  • Set the output binary name:
    go build -o app .
 
  • Cross-compile for Linux (from macOS/Windows):
    GOOS=linux GOARCH=amd64 go build -o app-linux .
 

Hard words (English)

  • binary /ˈbaɪnəri/: file thực thi
  • cross-compile /ˌkrɔːs kəmˈpaɪl/: biên dịch chéo
  • architecture (arch) /ˈɑːrkɪtektʃər/: kiến trúc CPU
  • executable /ɪɡˈzekjətəbəl/: có thể chạy được
go/tooling/go_build.txt · Last modified: by phong2018