Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Format string for writing out the type-specific receiver. May of // course be set to something completely different. The formatted // operands are the type name passed twice. FormatReceiver = "func (t %s) String() string { return \"%s\" }\n" // Format string for determining the generated filenames. FormatFilename = "%s_strings.go" )
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct { // Patterns passed to packages.Load. Patterns []string // List of regular expressions to determine which types are included. // Empty list means to include all types by default. Includes []*regexp.Regexp // List of regular expressions to determine which types are ignored. // Ignores takes precedence over Inludes. Ignores []*regexp.Regexp // Format string for writing out the type's String() receiver. Format string // Function used to create the output Writer for generated files. If // left empty, the generated output is directed to a file in the target // package with its filename determined by FormatFilename. WriteCloserCreator WriteCloserCreator // Determines where generated output is written. If set to nil, // WriteCloserCreator is used. Output io.WriteCloser // Determines where Generator diagnostic output is written. If set to // nil, os.Stderr will be used. If output should be discarded, something // like io.Discard may be used. DiagnosticOutput io.Writer // If set true, the output stream will not be closed after package's // code generation. NoClose bool // Format string for writing out the header of generated files. The // format operand is the package name. May be left empty. Header string // String to write after the generated file's package has been declared // and before the type-specific part begins. Useful for declaring things // such as imports. Preamble string // If set true, generation will not output "package <name>". NoPackage bool }
Generator contains the configuration for String() generation based on package's type names.
type WriteCloserCreator ¶
type WriteCloserCreator func(filepath string, module string) (io.WriteCloser, error)
Click to show internal directories.
Click to hide internal directories.