gogen

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanImports

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

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 GetPackageImports

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

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,
	receiverDecl string,
	fnName string,
	overrides map[string]string,
)

func WriteImportDecls

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

Types

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