Documentation
¶
Overview ¶
Package packagen generate Go source code from source package(s). It is largely inspired by https://github.com/golang/tools/cmd/bundle.
Transformations can be applied to the resulting AST before outputting it.
Limitations: - no asm, no cgo, no build tags
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bundle ¶ added in v0.0.10
func Bundle(out io.Writer, o BundleOption) error
Bundle packs the package identified by o.PkgName into a bundle file and writes it to the given io.Writer.
func ExtendStruct ¶ added in v0.0.10
func ExtendStruct(out, methods io.Writer, o ExtendOption) (string, error)
ExtendStruct adds fields and methods from one struct to another. It returns the name of the file where the destination struct is located and writes the new destination content to out and its new methods (if any) to methods.
Types ¶
type BundleOption ¶ added in v0.0.10
type BundleOption struct {
Log *log.Logger
Pkg string // Package to be processed
NewPkg string // Name of the resulting package (default=current working dir package)
Prefix string // Prefix for the global identifiers (default=packageName_)
Types map[string]string // Map the names of the types to be renamed to their new one
RmTypes map[string]bool // Named types to be removed
Const map[string]int // Values for const to be updated
RmConst map[string]bool // Constants to be removed
}
BundleOption defines the options for the Bundle processor.
type ExtendOption ¶ added in v0.0.10
type ExtendOption struct {
Log *log.Logger
SrcPkg string // Package of the source type
Src string // Name of the struct type to be used as source
DstPkg string // Package of the destination type
Dst string // Name of the struct type to be extended
Fields map[string]string // Map field name to the new type
FieldPrefix string // Prefix to be used for the added fields
MethodPrefix string // Prefix to be used for method names
}
ExtendOption defines the options in use when extending a type.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
packagen
command
|
|
|
examples
|
|
|
slice
This file is the reference implementation of the Slice type.
|
This file is the reference implementation of the Slice type. |
|
internal
|
|
|
par
Straight copy from https://github.com/golang/go/tree/master/src/cmd/go/internal/par.
|
Straight copy from https://github.com/golang/go/tree/master/src/cmd/go/internal/par. |