An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/chanced/genenums

genenums is a tool to automate the creation of methods that satisfy the fmt.Stringer, json.Marshaler and json.Unmarshaler interfaces. Given the name of a (signed or unsigned) integer type T that has constants defined, genenums will create a new self-contained Go source file implementing The file is created in the same package and directory as the package that defines T. It has helpful defaults designed for use with go generate. genenums is a simple implementation of a concept and the code might not be the most performant or beautiful to read. For example, given this snippet, running this command in the same directory will create the file pill_gen.go, in package painkiller, containing a definition of That method will translate the value of a Pill constant to the string representation of the respective constant name, so that the call fmt.Print(painkiller.Aspirin) will print the string "Aspirin". Typically this process would be run using go generate, like this: If multiple constants have the same value, the lexically first matching name will be used (in the example, Acetaminophen will print as "Paracetamol"). With no arguments, it processes the package in the current directory. Otherwise, the arguments must name a single directory holding a Go package or a set of Go source files that represent a single Go package. The -type flag accepts a comma-separated list of types so a single run can generate methods for multiple types. The default output file is t_gen.go, where t is the lower-cased name of the first type listed. The suffix can be overridden with the -suffix flag and a prefix may be added with the -prefix flag.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/chanced/genenums
License: Apache-2.0
Latest release: over 4 years ago
First release: over 4 years ago
Namespace: github.com/chanced
Last synced: 22 days ago

    Loading...
    Readme
    Loading...