model

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0 Imports: 5 Imported by: 207

Documentation

Overview

Package model contains the data model necessary for generating mock implementations.

Index

Constants

This section is empty.

Variables

View Source
var ErrorInterface = Interface{
	Name: "error",
	Methods: []*Method{
		{
			Name: "Error",
			Out: []*Parameter{
				{
					Name: "",
					Type: PredeclaredType("string"),
				},
			},
		},
	},
}

ErrorInterface represent built-in error interface.

Functions

This section is empty.

Types

type ArrayType

type ArrayType struct {
	Len  int // -1 for slices, >= 0 for arrays
	Type Type
}

ArrayType is an array or slice type.

func (*ArrayType) String

func (at *ArrayType) String(pm map[string]string, pkgOverride string) string

type ChanDir

type ChanDir int

ChanDir is a channel direction.

const (
	RecvDir ChanDir = 1
	SendDir ChanDir = 2
)

Constants for channel directions.

type ChanType

type ChanType struct {
	Dir  ChanDir // 0, 1 or 2
	Type Type
}

ChanType is a channel type.

func (*ChanType) String

func (ct *ChanType) String(pm map[string]string, pkgOverride string) string

type FuncType

type FuncType struct {
	In, Out  []*Parameter
	Variadic *Parameter // may be nil
}

FuncType is a function type.

func (*FuncType) String

func (ft *FuncType) String(pm map[string]string, pkgOverride string) string

type Interface

type Interface struct {
	Name    string
	Methods []*Method
}

Interface is a Go interface.

func InterfaceFromInterfaceType

func InterfaceFromInterfaceType(it reflect.Type) (*Interface, error)

InterfaceFromInterfaceType returns a pointer to an interface for the given reflection interface type.

func (*Interface) AddMethod added in v1.5.0

func (intf *Interface) AddMethod(m *Method)

AddMethod adds a new method, de-duplicating by method name.

func (*Interface) Print

func (intf *Interface) Print(w io.Writer)

Print writes the interface name and its methods.

type MapType

type MapType struct {
	Key, Value Type
}

MapType is a map type.

func (*MapType) String

func (mt *MapType) String(pm map[string]string, pkgOverride string) string

type Method

type Method struct {
	Name     string
	In, Out  []*Parameter
	Variadic *Parameter // may be nil
}

Method is a single method of an interface.

func (*Method) Print

func (m *Method) Print(w io.Writer)

Print writes the method name and its signature.

type NamedType

type NamedType struct {
	Package string // may be empty
	Type    string
}

NamedType is an exported type in a package.

func (*NamedType) String

func (nt *NamedType) String(pm map[string]string, pkgOverride string) string

type Package

type Package struct {
	Name       string
	PkgPath    string
	Interfaces []*Interface
	DotImports []string
}

Package is a Go package. It may be a subset.

func (*Package) Imports

func (pkg *Package) Imports() map[string]bool

Imports returns the imports needed by the Package as a set of import paths.

func (*Package) Print

func (pkg *Package) Print(w io.Writer)

Print writes the package name and its exported interfaces.

type Parameter

type Parameter struct {
	Name string // may be empty
	Type Type
}

Parameter is an argument or return parameter of a method.

func (*Parameter) Print

func (p *Parameter) Print(w io.Writer)

Print writes a method parameter.

type PointerType

type PointerType struct {
	Type Type
}

PointerType is a pointer to another type.

func (*PointerType) String

func (pt *PointerType) String(pm map[string]string, pkgOverride string) string

type PredeclaredType

type PredeclaredType string

PredeclaredType is a predeclared type such as "int".

func (PredeclaredType) String

func (pt PredeclaredType) String(map[string]string, string) string

type Type

type Type interface {
	String(pm map[string]string, pkgOverride string) string
	// contains filtered or unexported methods
}

Type is a Go type.

Jump to

Keyboard shortcuts

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