Yet another "generic" code generation tool. Inspired by typewriter, go_generics and genny.
Basic CLI help:
funcy --help
funcy is a "generic" code generation tool
Usage:
funcy [flags] TYPE
Flags:
-g, --generators strings list of generators to run
-f, --group-fields strings name of fields on type to group by
-h, --help help for funcy
-k, --key-field string name of field on type to populate map key (default "ID")
-p, --path string Type import path, can be relative to GOPATH
-v, --verbose verbose mode
See the example, but given a .go
with:
package mypackage
// Foo a common name for junk
type Foo struct {
Key int
StringField string
EmbeddedField *Bar
InterfaceField D
}
Add a go:generate
like:
//go:generate funcy --path to/my-package -k Key Foo
Or invoke manually, via make
, whatever, and you'll get this.
Maps (requires --key-field
match):
Slices:
- SliceOf
- SliceOfAsMap (requires
--key-field
match) - SliceOfGroupBys