https://github.com/gvcgo/gobuilder
An enhancement for official <go build>.
https://github.com/gvcgo/gobuilder
build cgo cross-compilation cross-compile cross-platform garble go golang osslsigncode pack script-free upx xgo zip
Last synced: about 2 months ago
JSON representation
An enhancement for official <go build>.
- Host: GitHub
- URL: https://github.com/gvcgo/gobuilder
- Owner: gvcgo
- License: mit
- Created: 2024-04-11T11:46:55.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-15T04:17:38.000Z (about 1 year ago)
- Last Synced: 2025-04-05T13:05:57.463Z (3 months ago)
- Topics: build, cgo, cross-compilation, cross-compile, cross-platform, garble, go, golang, osslsigncode, pack, script-free, upx, xgo, zip
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 53
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[中文](https://github.com/gvcgo/gobuilder/blob/main/docs/README_CN.md) | [En](https://github.com/gvcgo/gobuilder)
### What's gobuilder?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.
### Features
- 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](https://github.com/gvcgo/version-manager). **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](https://stackoverflow.com/questions/84847/how-do-i-create-a-self-signed-certificate-for-code-signing-on-windows).
```bash
New-SelfSignedCertificate -Type Custom -Subject "CN=, O=, C=CN, L=, S=" -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)
```### How to use?
- Install
```bash
go install github.com/gvcgo/gobuilder/cmd/[email protected]
```- Usage
```bash
gber build
```**Note**: If you need to inject variables when building go source code, "$" should be replaced with "#".
```bash
# 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
```### Demo
compiling [vmr](https://github.com/gvcgo/version-manager) for different platforms and architectures.

### Dependencies
- [go compiler](https://go.dev/dl/) (required)
- [garble](https://github.com/burrowers/garble) (optional)
- [osslsigncode](https://github.com/mtrojnar/osslsigncode) (optional)
- [upx](https://github.com/upx/upx) (optional)
- [xgo](https://github.com/crazy-max/xgo) (optional)