4 GenX: Generics For Go, Yet Again.

github.com godoc.org goreportcard.com posted by OneOfOne 2642 days ago  

A slightly more powerful generic code generator with a very simple interface.

Features:

  • * It can be *easily* used with `go generate`, from the command line or as a library.
  • * `cmd/genx` Uses local files, packages, and optionally uses `go get` (with the `-get` flag) if the remote package doesn't exist.
  • * You can rewrite, remove and change pretty much everything.
  • * Allows you to merge a package of multiple files into a single one.
  • * *Safely* remove functions and struct fields.
  • * Automatically passes all code through `x/tools/imports` (aka `goimports`).
  • * If you intend on generating files in the same package, you may add `// +build genx` to your template(s).
  • * Transparently handles [genny](https://github.com/cheekybits/genny)'s `generic.Type`.
  • * Supports a few [seeds](https://github.com/OneOfOne/genx/tree/master/seeds/).
  • * Adds build tags based on the types you pass, so you can target specifc types (ex: `// +build genx_t_string` or `// +build genx_vt_builtin` )
  • * Automatically handles nil returns, will return the zero value of the type.
  • * Doesn't need modifying the source package if there's only one type involved.
Register to comment or vote on this story