config

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

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
	Name        string   `json:"name"`        // 配置文件名称
	Paths       []string `json:"paths"`       // 配置文件路径
	Environment string   `json:"environment"` // 环境变量
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(name string, paths ...string) *Config

NewConfig 实例化配置

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig 实例化配置

func (*Config) Bind

func (c *Config) Bind(cfg any) error

Bind 初始化配置到cfg对象里面

func (*Config) BindByString

func (c *Config) BindByString(configStr string, cfg any) error

func (*Config) Callback

func (c *Config) Callback(configStr string) error

func (*Config) ReadConfig

func (c *Config) ReadConfig(needEnv bool) *Config

ReadConfig 读取配置文件 needEnv 是否需要合并配置文件

func (*Config) Save

func (c *Config) Save()

Save 保存配置到文件

Jump to

Keyboard shortcuts

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