gogen

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFuncMock added in v0.1.9

func GenerateFuncMock(
	writer io.Writer,
	mockPkg string,
	mockClz string,
	fnName string,
	paramInfos []*gosyntax.FieldDeclInfo,
	returnInfos []*gosyntax.FieldDeclInfo,
	signature *types.Signature,
)

GenerateFuncMock generates function mock implementation based on FieldDeclInfo abstraction

func LookupInPackageScope

func LookupInPackageScope(pkg *packages.Package, name string) types.Object

func MockFunc added in v0.1.9

func MockFunc(
	writer io.Writer,
	mockPkg string,
	mockClz string,
	fset *token.FileSet,
	fnName string,
	fnParams *ast.FieldList,
	fnReturns *ast.FieldList,
	signature *types.Signature,
)

MockFunc generates a mocking method on mockClz class generate mockery (https://github.com/vektra/mockery) compatible mocking implementation from syntax based declarations

func SetImportSpecs

func SetImportSpecs(f *ast.File, imports []*ast.ImportSpec)

SetImportSpecs sets ImportSpecs in f's Decls section using the passed ImportSpecs

func WriteFuncDecls

func WriteFuncDecls(
	writer io.Writer,
	fset *token.FileSet,
	file *ast.File,
)

func WriteFuncWithLocalOverrides

func WriteFuncWithLocalOverrides(
	writer io.Writer,
	fset *token.FileSet,
	fnSpec *ast.FuncDecl,
	fnName string,
	overrides map[string]string,
)

func WriteImportDecls

func WriteImportDecls(writer io.Writer, imports []ImportSpec)

Types

type ImportSpec

type ImportSpec struct {
	Name string
	Path string
}

func AppendImportSpec

func AppendImportSpec(specs []ImportSpec, name, p string) []ImportSpec

func CleanImports

func CleanImports(f *ast.File, cleanedImports []ImportSpec) []ImportSpec

func GetFileImports

func GetFileImports(file *ast.File) []ImportSpec

func GetPackageImports

func GetPackageImports(pkg *packages.Package) []ImportSpec

func (*ImportSpec) IsNameDefault

func (s *ImportSpec) IsNameDefault() bool

type ReturnFieldBinding added in v0.1.9

type ReturnFieldBinding struct {
	FuncInvokeParamsExpr string
	MockCallExpr         string
	Fields               []ReturnFieldBindingSpec
}

type ReturnFieldBindingSpec added in v0.1.9

type ReturnFieldBindingSpec struct {
	Name         string
	Typ          string
	TypeFuncDecl string
}

Jump to

Keyboard shortcuts

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