internal

package
v3.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoConfigFile         = fmt.Errorf("no config file exists")
	ErrNoGoFilesFoundInRoot = fmt.Errorf("no go files found in root search path")
	ErrPkgNotFound          = fmt.Errorf("package not found in config")
	ErrGoModNotFound        = fmt.Errorf("no go.mod file found")
	ErrGoModInvalid         = fmt.Errorf("go.mod file has no module line")
)

Functions

This section is empty.

Types

type Formatter

type Formatter string
const (
	FormatGofmt     Formatter = "gofmt"
	FormatGoImports Formatter = "goimports"
	FormatNoop      Formatter = "noop"
)

type Interface added in v3.1.0

type Interface struct {
	Name       string // Name of the type to be mocked.
	TypeSpec   *ast.TypeSpec
	GenDecl    *ast.GenDecl
	FilePath   string
	FileSyntax *ast.File
	Pkg        *packages.Package
	Config     *config.Config
}

func NewInterface added in v3.1.0

func NewInterface(
	name string,
	typeSpec *ast.TypeSpec,
	genDecl *ast.GenDecl,
	filepath string,
	fileSyntax *ast.File,
	pkg *packages.Package,
	config *config.Config,
) *Interface

type NodeVisitor

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

func NewNodeVisitor

func NewNodeVisitor(ctx context.Context) *NodeVisitor

func (*NodeVisitor) DeclaredInterfaces

func (nv *NodeVisitor) DeclaredInterfaces() []declaredInterface

func (*NodeVisitor) Visit

func (nv *NodeVisitor) Visit(node ast.Node) ast.Visitor

type Parser

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

func NewParser

func NewParser(buildTags []string, mockeryConfig config.RootConfig) *Parser

func (*Parser) ParsePackages

func (p *Parser) ParsePackages(ctx context.Context, packageNames []string) ([]*Interface, error)

type RemoteTemplate

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

func NewRemoteTemplate

func NewRemoteTemplate(templateURL string, schemaURL string) *RemoteTemplate

func (*RemoteTemplate) Schema

Schema returns the JSON Schema as a string. It downloads the remote schema once and caches the result for future calls.

func (*RemoteTemplate) Template

func (r *RemoteTemplate) Template(ctx context.Context) (string, error)

Template will return the template string. It downloads the remote template once and caches the result for future calls.

type TemplateGenerator

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

func NewTemplateGenerator

func NewTemplateGenerator(
	ctx context.Context,
	srcPkg *packages.Package,
	outPkgFSPath string,
	templateName string,
	templateSchema string,
	requireSchemaExists bool,
	remoteTemplateCache map[string]*RemoteTemplate,
	formatter Formatter,
	pkgConfig *config.Config,
	pkgName string,
	forceInPackage *bool,
) (*TemplateGenerator, error)

func (*TemplateGenerator) Generate

func (g *TemplateGenerator) Generate(
	ctx context.Context,
	interfaces []*Interface,
) ([]byte, error)

Directories

Path Synopsis
recursive_generation/subpkg_with_only_autogenerated_files
Code generated by an arbitrary code generator thingy.
Code generated by an arbitrary code generator thingy.

Jump to

Keyboard shortcuts

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