gen

package module
v0.0.0-...-1023f2c Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2018 License: MIT Imports: 18 Imported by: 0

README

gen

This is my personal project, unrelated to my work at Google.

Limitations

  • Have to invoke manually (not part of Go toolchain). Use "go generate".

  • Can't instantiate with a type from the same package. Must move to another package.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Instantiate

func Instantiate(pkg *Package, pkgName string, bindings map[string]types.Type) error

Instantiate instantiates the generic package, giving the resulting package the given name. The bindings are a map from generic parameter name to the instantiated type of the parameter. After Instantiate returns, the AST of pkg has been altered, the FileSet has been updated to match and the new package has been typechecked. Note: the AST may be altered even if Instantiate returns an error.

func NewBindingMap

func NewBindingMap(specs map[string]string) (map[string]types.Type, error)

func ParseBindingSpec

func ParseBindingSpec(s string) (param, arg string, err error)

Parse a string of the form "param:type", where param is an identifier and type is a possibly-qualified type name, like "fmt.Stringer" or "golang.org/x/net/context.Context".

Types

type Binding

type Binding struct {
	// contains filtered or unexported fields
}

type Package

type Package struct {
	Path string

	Apkg   *astPackage
	Tpkg   *types.Package
	Params []string
	// contains filtered or unexported fields
}

func Check

func Check(path, dir string, params []string) (*Package, error)

Check checks the generic package at path (with respect to dir) for errors. It returns the first error it finds.

func (*Package) Name

func (p *Package) Name() string

func (*Package) String

func (p *Package) String() string

func (*Package) Write

func (p *Package) Write(dir string) error

Write writes the files of p to the directory dir. The directory must already exist.

Directories

Path Synopsis
examples
geo

Jump to

Keyboard shortcuts

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