stringify

command module
v0.0.0-...-70e9807 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2016 License: MIT Imports: 16 Imported by: 0

README

stringify

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 godoc.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL