This simple bash/zsh function automates a make-based Go project that uses modules (No GOPATH muckery required).
Copy the goproject file somewhere on your $PATH and chmod +x it, or copy the function definition into your own bash/zsh script.
This is little more than a wrapper around running go mod init <etc>, writing a few files so you don't have to think about it. Expected outputs are shown in comments following each command.
- Set up a new project
$ goproject github.com/damienstanton smoketest
# go: creating new go.mod: module github.com/damienstanton/smoketest- Run unit tests (the previous command automatically
cds you into the new project)
$ make test
# === RUN TestNothing
# --- PASS: TestNothing (0.00s)
# PASS
# coverage: 0.0% of statements
# ok github.com/damienstanton/smoketest 0.126s- Build the program
$ make build
# ls bin/
# smoketest- Run the program (automatically builds)
$ make run
# smoketest OK- Don't end your project name with
_test, as this breaks the ability to run/test.