generate

package
v0.0.0-...-c7c4365 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package generate generates method sets for Go types.

Index

Constants

View Source
const HeaderGenerated = "Code generated by angryjet. DO NOT EDIT."

HeaderGenerated is added to all files generated by angryjet. See https://github.com/golang/go/issues/13560#issuecomment-288457920.

Variables

This section is empty.

Functions

func ProducedNothing

func ProducedNothing(data []byte) bool

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

func WriteMethods(p *packages.Package, ms method.Set, file string, wo ...WriteOption) error

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.

Jump to

Keyboard shortcuts

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