generator

package
v0.0.0-...-c1b3f41 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator generates mock implementations of Go interfaces.

func New

func New(p Parser, r Renderer) *Generator

New returns a new generator.

func (*Generator) Generate

func (g *Generator) Generate(importPath string, options Options, interfaces ...string) ([]byte, error)

Generate generates mock implementations of the specified Go interfaces for the given import path.

type Options

type Options struct {
	MockPackage   string
	MockNames     map[string]string
	FileName      string
	Substitutions map[string]string
}

Options represent a set of options to use when generating mock implementations.

type Parser

type Parser interface {
	Parse(importPath string, interfaces ...string) (internal.Package, error)
}

Parser returns the package for the given import path with filtered interfaces.

type Renderer

type Renderer interface {
	Render(w io.Writer, p internal.Package, substitutions map[string]string) error
}

Renderer allows mock implementation rendering.

Jump to

Keyboard shortcuts

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