tools

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefNameIsAllowed

func DefNameIsAllowed(name string) error

DefNameIsAllowed returns an error if the definition name is not allowed.

func FormatDefName

func FormatDefName(name string) string

FormatDefName is the function used to turn the definition name into something that can be used as a method name for the generated container.

func FormatPkgName

func FormatPkgName(name string) string

FormatPkgName formats a package name by keeping only the letters.

func WriteTemplate

func WriteTemplate(output string, tmpl string, data interface{}) error

WriteTemplate executes the given templates with the given data. Then it stores the result in the output file.

Types

type ParamInfo

type ParamInfo struct {
	Name                 string
	Index                string
	ServiceName          string
	Type                 string
	Empty                string
	UndefinedStructParam bool
	Def                  *ScannedDef
}

ParamInfo contains the parsed information about a parameter.

type ParamScanner

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

ParamScanner helps the Scanner. It scans information about params.

func (*ParamScanner) Scan

func (s *ParamScanner) Scan(scan *Scan) error

Scan updates the given Scan with data about params.

type Provider

type Provider interface {
	Names() []string
	Get(name string) (*dingo.Def, error)
}

Provider is an interface that contains the public methods of the generated Provider. It is used in the Scanner because it avoids generating a Scanner from a template to include the generated Provider.

type RegisteredType

type RegisteredType struct {
	Type       string
	EmptyValue string
}

RegisteredType is the representation of a type. It contains the type name and how to write its empty value in a go file.

func NewRegisteredType

func NewRegisteredType(typ, empty string) *RegisteredType

NewRegisteredType is the RegisteredType constructor.

type Scan

type Scan struct {
	TypeManager          *TypeManager
	ImportsWithoutParams map[string]string
	Defs                 []*ScannedDef
}

Scan contains the parsed information about the service definitions.

type ScannedDef

type ScannedDef struct {
	Def           *dingo.Def
	Name          string
	FormattedName string
	Scope         string
	ObjectType    string
	EmptyObject   string
	BuildIsFunc   bool
	BuildType     string
	Params        map[string]*ParamInfo
	CloseType     string
}

ScannedDef contains the parsed information about a service definition.

func (*ScannedDef) BuildDependsOnRawDef

func (def *ScannedDef) BuildDependsOnRawDef() bool

BuildDependsOnRawDef returns true if the service contructor needs the definition contained in the Provider.

func (*ScannedDef) ParamsString

func (def *ScannedDef) ParamsString() string

ParamsString returns the parameters as they should appear in a structure inside a go file.

type Scanner

type Scanner struct {
	Provider     Provider
	ParamScanner ParamScanner
	// contains filtered or unexported fields
}

Scanner analyzes the definitions provided by a Provider.

func (*Scanner) Scan

func (s *Scanner) Scan() (*Scan, error)

Scan creates the Scan for the Scanner definitions.

type TypeManager

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

TypeManager maintains a list of all the import paths that are used in the types that it has registered. It associates a unique alias to all the import paths.

func (*TypeManager) Imports

func (tm *TypeManager) Imports() map[string]string

Imports returns a map with all the imports that are used in the registered types. The key is the import path and the value is the alias that has been given by the TypeManager.

func (*TypeManager) Register

func (tm *TypeManager) Register(t reflect.Type) (*RegisteredType, error)

Register adds a new type in the TypeManager.

Jump to

Keyboard shortcuts

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