option

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFile

func AddFile(filePath string, parser koanf.Parser) error

func AddJSONFile

func AddJSONFile(filePath string) error

func BindKeyedOptionPath

func BindKeyedOptionPath[T any](repo *Repository, key string, path string)

func BindKeyedOptionValue

func BindKeyedOptionValue[T any](repo *Repository, key string, value T)

func BindOptionPath

func BindOptionPath[T any](repo *Repository, path string)

func BindOptionValue

func BindOptionValue[T any](repo *Repository, value T)

func BindType

func BindType[T any](key string)

BindType 将类型绑定到 key,而后通过 Get 可以直接获取配置数据

func Get

func Get[T any]() (out *T, err error)

Get 通过类型获取配置

func GetByKey

func GetByKey(key string, inout interface{}) error

GetByKey 通过 key 返回配置

func GetInout

func GetInout(inout any) error

GetInout 通过传入 inout 变量类型获取配置,并写入 inout

Types

type IOptionInjector

type IOptionInjector interface {
	// contains filtered or unexported methods
}

type Option

type Option[T any] struct {
	// contains filtered or unexported fields
}

func (*Option[T]) Get

func (ss *Option[T]) Get() T

func (*Option[T]) GetKeyed

func (ss *Option[T]) GetKeyed(key string) T

type Repository

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

func NewOptionRepository

func NewOptionRepository() *Repository

func (*Repository) BindByPath

func (ss *Repository) BindByPath(key string, ty reflect.Type, path string)

func (*Repository) BindByValue

func (ss *Repository) BindByValue(key string, ty reflect.Type, value any)

func (*Repository) GetOption

func (ss *Repository) GetOption(ty reflect.Type) any

Jump to

Keyboard shortcuts

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