← All tools

lesiw/gorc

Popularity 65 Updated Development & Build

go.rc is a Makefile for Go projects.

githubauto-collected

Installation

A directly usable install command is not verified yet. Check the project documentation or releases.

lesiw.io/gorc

gorc runs the go command with per-project command definitions from a go.rc file. A companion gofmt shim does the same for formatting, applying format commands from a go.fmt file.

test (
    CGO_ENABLED=0 go test $GOARGS -shuffle=on -timeout=5s $GOFLAGS
    CGO_ENABLED=1 go test $GOARGS -shuffle=on -timeout=30s -race $GOFLAGS
)
vet go tool golangci-lint run $GOARGS

With gorc installed, running a defined verb runs the configured commands in its place. Every other invocation passes through to the real go command unchanged:

$ go test ./...
go.rc: CGO_ENABLED=0 go test ./... -shuffle=on -timeout=5s
go.rc: CGO_ENABLED=1 go test ./... -shuffle=on -timeout=30s -race

Quick Start

go install lesiw.io/gorc/go@latest
go install lesiw.io/gorc/gofmt@latest

The Go bin directory must come before the Go distribution in PATH:

export PATH="$(go env GOPATH)/bin:$PATH"

go.rc

The nearest go.rc, found by searching upward from the current directory, defines the project's verbs. Groups run in order and stop at the first failure:

test (
    CGO_ENABLED=0 go test -shuffle=on
    CGO_ENABLED=1 go test -shuffle=on -race
)

New verbs define new subcommands:

xcompile GOOS=linux GOARCH=arm64 go build $GOARGS

Commands run exactly as written. Arguments after the verb carry over only where a command asks for them: $GOARGS expands to the invocation's arguments, such as package patterns, and $GOFLAGS expands to its flags:

test go test $GOARGS -shuffle=on $GOFLAGS

Here go test ./... -run TestFoo runs go test ./... -shuffle=on -run TestFoo. Editor and IDE test runners keep working: their -run, -timeout, and -json flags flow into the configured commands. Flags written after $GOFLAGS cannot be overridden by the caller. Spell values of flags the go command does not document as -flag=value. Every other $NAME expands from the environment.

Commands are not interpreted by a shell — no pipes, redirections, or globs. Lines split into words by go:generate's rules: spaces and tabs separate words, a word beginning with a double quote is a Go string literal, // introduces a comment, and a command may begin with KEY=VALUE environment assignments. Full syntax: pkg.go.dev/lesiw.io/gorc/go.