enum

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransformers = map[string]Transformer{
	"regex": transformRegex,
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Unknown  string
	Enabled  bool
	Excludes IDPatterns
}

type Enum

type Enum struct {
	Type    *types.Named
	Members map[string]any
}

func Detect

func Detect(named *types.Named) (Enum, bool)

type IDPattern

type IDPattern struct {
	Path *regexp.Regexp
	Name *regexp.Regexp
}

type IDPatterns

type IDPatterns []IDPattern

func (IDPatterns) Matches

func (ids IDPatterns) Matches(path, name string) bool

type TransformContext

type TransformContext struct {
	Source Enum
	Target Enum
	// Config is user definable config
	Config string
}

type Transformer

type Transformer func(context TransformContext) (map[string]string, error)

Transformer transforms a source enum members to target enum members

The transformer must only return keys present inside the context.Source.Members and context.Target.Members, if something cannot be mapped by the transformer just skip the key and don't return it. An error by this methods aborts the aborts the whole goverter conversion, so only use it when there are config errors.

Jump to

Keyboard shortcuts

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