package exportdefault
import "github.com/ernesto-jimenez/gogen/exportdefault"
Package exportdefault provides the functionality to automatically generate package-level exported functions wrapping calls to a package-level default instance of a type.
This helps auto-generating code for the common use case where a package implements certain information as methods within a stub and, for convenience, exports functions that wrap calls to those methods on a default variable.
Some examples of that behaviour in the stdlib:
- `net/http` has `http.DefaultClient` and functions like `http.Get` just call the default `http.DefaultClient.Get`
- `log` has `log.Logger` and functions like `log.Print` just call the default `log.std.Print`
Index ¶
Types ¶
type Generator ¶
type Generator struct { Name string Imports map[string]string FuncNamePrefix string Include *regexp.Regexp Exclude *regexp.Regexp // contains filtered or unexported fields }
Generator contains the metadata needed to generate all the function wrappers arround methods from a package variable
func New ¶
New initialises a new Generator for the corresponding package's variable
Returns an error if the package or variable are invalid
func (*Generator) Write ¶
Write the generated code into the given io.Writer
Returns an error if there is a problem generating the code
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
exportdefault/_integration_test | |
exportdefault/_testpkg |
- Version
- v0.0.0-20180125220232-d7d4131e6607 (latest)
- Published
- Jan 25, 2018
- Platform
- linux/amd64
- Imports
- 16 packages
- Last checked
- 1 day ago –
Tools for package owners.