interfaces

package
v0.3.15 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MPL-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate added in v0.1.1

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

Generate 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 WithExtraImports added in v0.2.0

func WithExtraImports(f func(reflect.Method) []string) Option

func WithIncludeFunc

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

func WithSinglePackage added in v0.3.4

func WithSinglePackage(name string) 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

	// ExtraImports can add extra imports for a method
	ExtraImports func(reflect.Method) []string

	// SinglePackage allows to generate all passed clients into a single package.
	// The clients will get their package name as prefix to the interface name (e.g., s3.Client -> S3Client)
	SinglePackage string
}

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