go run, the way it should be
ARCHIVED: This is now the default behaviour of go run with go version 1.11+
Like go run, but instead of running a file it runs a package which can be pinned in vendor.
A few reasons:
go dep
This is particularly nice when committing go generated code so you are in control of when the generator updates.
For example if you were using campoy/jsonenums to generate some code you would install gorunpkg on your gopath. This is the only part that needs to be gopath wide and is small enough that it should be stable.
go get github.com/vektah/gorunpkg
add the dep to projects Gopkg.toml:
required = ["github.com/campoy/jsonenums"]
fetch and pin the dep:
dep ensure
add some code using it:
//go:generate gorunpkg github.com/campoy/jsonenums -type=Pill
package painkiller
type Pill int
const (
Placebo Pill = iota
Aspirin
Ibuprofen
Paracetamol
Acetaminophen = Paracetamol
)
then go generate:
go generate ./...