yamlconf

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigEngine

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

ConfigEngine 配置文件结构体

func NewConf

func NewConf(opts ...Option) *ConfigEngine

NewConf new an entry

func (*ConfigEngine) Apply added in v1.1.4

func (conf *ConfigEngine) Apply(opts []Option)

Apply 应用函数配置项

func (*ConfigEngine) Get

func (c *ConfigEngine) Get(name string, v interface{}) error

Get 从配置文件中获取值,v必须是一个指针类型

func (*ConfigEngine) GetBool

func (c *ConfigEngine) GetBool(name string, defaultValue bool) bool

GetBool 从配置文件中获取bool类型的值

func (*ConfigEngine) GetData

func (c *ConfigEngine) GetData() map[string]interface{}

GetData get data

func (*ConfigEngine) GetFloat32 added in v1.1.4

func (c *ConfigEngine) GetFloat32(name string, defaultValue float32) float32

GetFloat32 获取浮点数float32

func (*ConfigEngine) GetFloat64

func (c *ConfigEngine) GetFloat64(name string, defaultValue float64) float64

GetFloat64 从配置文件中获取Float64类型的值

func (*ConfigEngine) GetInt

func (c *ConfigEngine) GetInt(name string, defaultValue int) int

GetInt 从配置文件中获取int类型的值,defaultValue是默认值的

func (*ConfigEngine) GetInt64

func (c *ConfigEngine) GetInt64(name string, defaultValue int64) int64

GetInt64 get int64

func (*ConfigEngine) GetString

func (c *ConfigEngine) GetString(name string, defaultValue string) string

GetString 从配置文件中获取string类型的值

func (*ConfigEngine) GetStruct

func (c *ConfigEngine) GetStruct(name string, s interface{}) error

GetStruct 从配置文件中获取Struct类型的值 这里的struct是你自己定义的根据配置文件 s必须是传递结构体的指针 name是yaml定义的结构体名称

func (*ConfigEngine) GetValue added in v1.1.9

func (c *ConfigEngine) GetValue(key string) interface{}

GetValue get value from vp you can convert it use cast package eg:cast.ToString

func (*ConfigEngine) LoadConf

func (c *ConfigEngine) LoadConf(path string) error

LoadConf 加载yaml,yml内容,兼容之前的版本

func (*ConfigEngine) LoadData added in v1.1.4

func (c *ConfigEngine) LoadData() error

LoadData 加载yaml,yml内容

type Option added in v1.1.4

type Option func(conf *ConfigEngine)

Option 配置项采用功能函数模式

func WithDir added in v1.1.4

func WithDir(dir string) Option

WithDir 设置配置文件目录

func WithFilename added in v1.1.4

func WithFilename(f string) Option

WithFilename 设置配置文件名,比如app.yaml,app.env,app.yml,app.json

func WithWatchFile added in v1.1.4

func WithWatchFile(b bool) Option

WithWatchFile 是否监听文件变化

Jump to

Keyboard shortcuts

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