exportdefault

package
v0.0.0-...-d7d4131 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2018 License: MIT Imports: 16 Imported by: 3

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

func New(pkg string, variable string) (*Generator, error)

New initialises a new Generator for the corresponding package's variable

Returns an error if the package or variable are invalid

func (*Generator) Write

func (g *Generator) Write(w io.Writer) error

Write the generated code into the given io.Writer

Returns an error if there is a problem generating the code

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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