Go
GoBuild builds the Go module in src/ with the Go your group pins, runs go test, and builds a static binary when the module has a main package.
GoBuildplinto create go-service HelloApp (or go-lib)The project
The module is src/. Tests go next to the code, as *_test.go files, never in tst/.
{
name = HelloApp
version = 1.0
build = GoBuild
# main = src/cmd/server a program: the package main `plinto run` starts (src for src/ itself)
build-dependencies: {
GoBuild = 1.0
Go = 1.27
}
dependencies: {
XText = v0.21.0 # golang.org/x/text, imported
}
}
A program
A project that names its package main is a program: main = src when it is src/ itself, or main = src/cmd/server for one of its folders. plinto run builds it and starts it, with the arguments args = [--port, 8080] names first. A release carries the module for the projects that use it, and the program's binary next to it.
Settings
configuration/GoBuild.config takes these keys:
| Key | What it does |
|---|---|
cgo |
true to build with cgo (default false, so binaries are static) |
platforms |
the platforms a program's release carries a binary for, as well as the machine building it, such as [linux-x64, linux-aarch64] |
A program's binary for another platform is cross-compiled, which needs no C compiler with cgo off; with cgo = true, a binary is built for the machine building it only. Tests run on the machine building. GoBuild builds for linux-x64, linux-aarch64, mac-x64, mac-aarch64, windows-x64 and windows-aarch64.
# configuration/GoBuild.config: Linux servers on x86-64 and on ARM
platforms = [linux-x64, linux-aarch64]
Builds use only the pinned Go and modules: no network, no module proxy, and none of your own GO* variables.
Libraries
Go modules come in through an import: a group holds one version of each module.
$ plinto import go golang.org/x/text@v0.21.0
Each module is a package named after its path: golang.org/x/text is XText.
What it releases
The module's sources, and for a program HelloApp-1.0-bin-<platform>.tar.gz holding HelloApp/bin/HelloApp, built with -trimpath: one for the machine it builds on, and one for each other platform platforms lists.