Gorunpkg Save Abandoned

go run, the way it should be

Project README

ARCHIVED: This is now the default behaviour of go run with go version 1.11+

gorunpkg

Like go run, but instead of running a file it runs a package which can be pinned in vendor.

why

A few reasons:

  • you can pin the version you use to generate code using go dep
  • you can have different versions per project
  • you dont need to install the binary on your path at all

This is particularly nice when committing go generated code so you are in control of when the generator updates.

usage example

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 ./...
Open Source Agenda is not affiliated with "Gorunpkg" Project. README Source: vektah/gorunpkg
Stars
27
Open Issues
1
Last Commit
5 years ago

Open Source Agenda Badge

Open Source Agenda Rating