config

package
v3.8.16 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	*viper.Viper
}

func New

func New() *Config

func (*Config) BindStruct

func (c *Config) BindStruct(key string, data any) error

func (*Config) Bool

func (c *Config) Bool(key string, defVal ...bool) bool

获取 bool 类型配置, 如果不存在则返回默认值

func (*Config) Duration added in v3.8.16

func (c *Config) Duration(key string, defVal ...time.Duration) time.Duration

获取 time.Duration 类型配置, 如果不存在则返回默认值

func (*Config) Exists

func (c *Config) Exists(key string) bool

func (*Config) Float

func (c *Config) Float(key string, defVal ...float64) float64

获取 float64 类型配置, 如果不存在则返回默认值

func (*Config) Int

func (c *Config) Int(key string, defVal ...int) int

获取 Int 类型配置, 如果不存在则返回默认值

func (*Config) Int64

func (c *Config) Int64(key string, defVal ...int64) int64

获取 Int64 类型配置, 如果不存在则返回默认值

func (*Config) LoadDir

func (c *Config) LoadDir(dirPath string) error

LoadDir 加载目录中的所有配置文件

func (*Config) LoadFile added in v3.8.16

func (c *Config) LoadFile(filePath string) error

LoadFile 加载单个配置文件

func (*Config) String

func (c *Config) String(key string, defVal ...string) string

获取 String 类型配置, 如果不存在则返回默认值

func (*Config) Uint

func (c *Config) Uint(key string, defVal ...uint) uint

获取 Uint 类型配置, 如果不存在则返回默认值

Jump to

Keyboard shortcuts

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