Documentation
¶
Overview ¶
Program stringify is a replacement of stringer that produces lintable and testable string representations of constants.
It accepts exactly one const type to stringify and works within the file from which generate was run. For more details, see the README.md.
Suppose you have a file named message.go with the contents below.
package message //go:generate stringify EventLevel // EventLevel is the level for an Event. type EventLevel int32 // These are the event levels, based on syslog. const ( Emerg EventLevel = iota Alert Crit Err Warning Notice Info Debug )
Running go generate would produce a file named eventlevel_stringify.go and eventlevel_stringify_test.go that contains EventLevel.String() and NewEvent() functions as well as tests for those functions. Most notably, they should have 100% code coverage and pass vetting and linting.
Click to show internal directories.
Click to hide internal directories.