interfaces

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MPL-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateInterfaces

func GenerateInterfaces(clients []any, dir string, opts ...Option) error

GenerateInterfaces generates service interfaces to be used for generating mocks. The clients passed in as the first argument should be structs that will be used to generate the service interfaces. The second argument, dir, is the path to the output directory where the service interface files will be created.

func MethodHasAnyPrefix

func MethodHasAnyPrefix(m reflect.Method, prefixes []string) bool

MethodHasAnyPrefix returns true if the method name has any of the given prefixes.

func MethodHasAnySuffix

func MethodHasAnySuffix(m reflect.Method, suffixes []string) bool

MethodHasAnySuffix returns true if the method name has any of the given suffixes.

Types

type Option

type Option func(*Options)

func WithIncludeFunc

func WithIncludeFunc(f func(reflect.Method) bool) Option

type Options

type Options struct {
	// ShouldInclude tests whether a method should be included in the generated interfaces. If it returns true,
	// the method will be included. MethodHasPrefix and MethodHasSuffix can be used inside a custom function here
	// to customize the behavior.
	ShouldInclude func(reflect.Method) bool
}

func (*Options) SetDefaults

func (o *Options) SetDefaults()

Jump to

Keyboard shortcuts

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