Skip to content

shousper/go-funcy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-funcy

Yet another "generic" code generation tool. Inspired by typewriter, go_generics and genny.

Usage

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

Example

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.

Generators

Maps (requires --key-field match):

Slices:

About

Yet another code generation tool

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages