Gobuilder is a tool for building Go binaries. It is similar to the Go tool, but it supports building multiple binaries at once and supports custom build configurations without creating any script.
- Builds binaries for any platform from go source code.
- Cross-compilation for CGO using xgo. (optional)
- Packs binaries with UPX. (optional)
- Obfuscate binaries with garble for windows. (optional)
- Sign windows exe with osslsigncode. (optional)
- Zip binaries automatically.
- Builds binaries at anywhere in a go project.
- Remembers the build operations forever.
- No script is needed.
- Keep source code tidy. A dir named build is created, all the related files are restored in build.
Note: You can install upx and go compiler using VMR. osslsigncode needs manuall compilation. garble and xgo can be installed using go install xxx. xgo docker image is available at ghcr.io/crazy-max/xgo or crazymax/xgo.
For self-signed certificate for Windows, see here.
New-SelfSignedCertificate -Type Custom -Subject "CN=<name>, O=<company name>, C=CN, L=<location>, S=<location>" -KeyUsage DigitalSignature -FriendlyName "MailTool" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") -NotAfter (Get-Date).AddYears(10)
- Install
go install github.com/gvcgo/gobuilder/cmd/[email protected]
- Usage
gber build <your-go-build-flags-and-args>
Note: If you need to inject variables when building go source code, "$" should be replaced with "#".
# original
gber build -ldflags "-X main.GitTag=$(git describe --abbrev=0 --tags) -X main.GitHash=$(git show -s --format=%H) -s -w" ./cmd/vmr/
# replaced
gber build -ldflags "-X main.GitTag=#(git describe --abbrev=0 --tags) -X main.GitHash=#(git show -s --format=%H) -s -w" ./cmd/vmr
compiling vmr for different platforms and architectures.
- go compiler (required)
- garble (optional)
- osslsigncode (optional)
- upx (optional)
- xgo (optional)