Documentation ¶
Overview ¶
Package gengo is a code-generation framework.
Index ¶
- Constants
- func Execute(nameSystems namer.NameSystems, defaultSystem string, ...) error
- func ExtractCommentTags(marker string, lines []string) map[string][]string
- func ExtractSingleBoolCommentTag(marker string, key string, defaultVal bool, lines []string) (bool, error)
- func GoBoilerplate(headerFile, buildTag, generatedBy string) ([]byte, error)
Constants ¶
const StdBuildTag = "ignore_autogenerated"
StdBuildTag is a suggested build-tag which tools can use both as an argument to GoBoilerplate and to Execute.
const StdGeneratedBy = "// Code generated by GENERATOR_NAME. DO NOT EDIT."
StdGeneratedBy is a suggested "generated by" line which tools can use as an argument to GoBoilerplate.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute(nameSystems namer.NameSystems, defaultSystem string, getTargets func(*generator.Context) []generator.Target, buildTag string, patterns []string) error
Execute implements most of a tool's main loop.
func ExtractCommentTags ¶
ExtractCommentTags parses comments for lines of the form:
'marker' + "key=value".
Values are optional; "" is the default. A tag can be specified more than one time and all values are returned. If the resulting map has an entry for a key, the value (a slice) is guaranteed to have at least 1 element.
Example: if you pass "+" for 'marker', and the following lines are in the comments:
+foo=value1 +bar +foo=value2 +baz="qux"
Then this function will return:
map[string][]string{"foo":{"value1, "value2"}, "bar": {""}, "baz": {"qux"}}
func ExtractSingleBoolCommentTag ¶
func ExtractSingleBoolCommentTag(marker string, key string, defaultVal bool, lines []string) (bool, error)
ExtractSingleBoolCommentTag parses comments for lines of the form:
'marker' + "key=value1"
If the tag is not found, the default value is returned. Values are asserted to be boolean ("true" or "false"), and any other value will cause an error to be returned. If the key has multiple values, the first one will be used.
func GoBoilerplate ¶
GoBoilerplate returns the Go file header: - an optional build tag (negative, set it to ignore generated code) - an optional boilerplate file - an optional "generated by" comment
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
kilroy
kilroy is a trivial gengo/v2 program which adds a tag-method to types.
|
kilroy is a trivial gengo/v2 program which adds a tag-method to types. |
pointuh
pointuh is a trivial gengo/v2 program which consider its inputs, and emits to new packages the same types, except for structs, where all fields are pointers.
|
pointuh is a trivial gengo/v2 program which consider its inputs, and emits to new packages the same types, except for structs, where all fields are pointers. |
tracer
tracer is a trivial gengo/v2 program which prints the various hooks as they are called.
|
tracer is a trivial gengo/v2 program which prints the various hooks as they are called. |
Package generator defines an interface for code generators to implement.
|
Package generator defines an interface for code generators to implement. |
Package namer has support for making different type naming systems.
|
Package namer has support for making different type naming systems. |
Package parser provides code to parse go files, type-check them, extract the types.
|
Package parser provides code to parse go files, type-check them, extract the types. |
Package types contains go type information, packaged in a way that makes auto-generation convenient, whether by template or straight go functions.
|
Package types contains go type information, packaged in a way that makes auto-generation convenient, whether by template or straight go functions. |