Documentation ¶
Overview ¶
Package generate generates method sets for Go types.
Index ¶
Constants ¶
const ( // HeaderGenerated is added to all files generated by ndd-gen. // See https://github.com/golang/go/issues/13560#issuecomment-288457920. HeaderGenerated = "Code generated by ndd-gen. DO NOT EDIT." HeaderIgnoreAutoGenerated = "+build !ignore_autogenerated" )
Variables ¶
This section is empty.
Functions ¶
func ProducedNothing ¶
ProducedNothing returns true if the supplied data is either not a valid Go source file, or a valid Go file that contains no top level objects or declarations.
func WriteMethods ¶
WriteMethods writes the supplied methods for each object in the supplied package to the supplied file. Use WithMatcher to limit the objects for which methods will be written. Methods will not be generated if a method with the same name is already defined for the object outside of the supplied filename. Files will not be written if they would contain no methods.
Types ¶
type WriteOption ¶
type WriteOption func(o *options)
A WriteOption configures method generation behaviour.
func WithHeaders ¶
func WithHeaders(h ...string) WriteOption
WithHeaders specifies strings to be written as comments to the generated file, above the package definition. Single line strings use // comments, while multiline strings use /**/ comments.
func WithImportAliases ¶
func WithImportAliases(ia map[string]string) WriteOption
WithImportAliases configures a map of import paths to aliases that will be used when generating code. For example if a generated method requires "example.org/foo/bar" it may refer to that package as "foobar" by supplying map[string]string{"example.org/foo/bar": "foobar"}
func WithMatcher ¶
func WithMatcher(m match.Object) WriteOption
WithMatcher specifies an Object matcher that is used to filter the Objects within the package down to the set that need the generated methods.