maps

package
v0.0.86 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTag = "json"

DefaultTag is the default tag for binding

Variables

View Source
var EmptyBinder = Binder(&emptyBinder{})

EmptyBinder is a variable that holds an instance of the emptyBinder struct, which implements the Binder interface.

Functions

This section is empty.

Types

type Binder

type Binder interface {
	Bind(typ reflect.Type, tag string, target string)
	Convert(name string) string
}

Binder is a binding interface

func NewBinder

func NewBinder() Binder

NewBinder returns a new instance of the binds struct, which implements the Binder interface.

type Map

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

Map is a binding map

func New

func New(opts ...Option) *Map

New returns a new instance of the Map struct, which represents a binding map. It applies the provided options to the map using the settings.Apply function.

func (*Map) Bind

func (m *Map) Bind(v interface{}, tag string)

Bind binds a value to a Map. The value can be of any type, but the type must be comparable. The tag parameter is used to identify the binding in the Map. If the type is already bound, the function does nothing. The Map will store the binder associated with the type.

func (*Map) Get

func (m *Map) Get(v interface{}) Binder

Get retrieves the binder associated with the provided value. If the value is a pointer, it gets the element type. Returns the binder if found in the map, otherwise returns an EmptyBinder.

type Option

type Option = func(*Map)

func WithSource

func WithSource(src string) Option

Jump to

Keyboard shortcuts

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