config

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 7 Imported by: 0

README

Config

  • env
  • file
  • etcd

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// conf file type
	FileTypeYaml = "yaml"
	FileTypeJson = "json"
	FileTypeToml = "toml"
)

Functions

func GetEnvString

func GetEnvString(key string, defaultValue string) string

GetEnvString get value from env.

func Load

func Load(filename string, val any) error

Load alias for config func.

func LoadJson

func LoadJson(filename string, val any) error

LoadJson alias for config func.

func LoadToml

func LoadToml(filename string, val any) error

LoadToml alias for config func.

func LoadWithType

func LoadWithType(filename string, cfgType string) (*viper.Viper, error)

LoadWithType load conf by file type.

func LoadYaml

func LoadYaml(filename string, val any) error

LoadYaml alias for config func.

Types

type Config

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

Config conf struct.

func New

func New(cfgDir string, opts ...Option) *Config

New create a config instance.

func (*Config) Load

func (c *Config) Load(filename string, val any) error

Load scan data to struct.

func (*Config) LoadJson

func (c *Config) LoadJson(filename string, val any) error

LoadJson scan data to struct.

func (*Config) LoadToml

func (c *Config) LoadToml(filename string, val any) error

LoadToml scan data to struct.

func (*Config) LoadWithType

func (c *Config) LoadWithType(filename string, cfgType string) (v *viper.Viper, err error)

LoadWithType load conf by file type.

func (*Config) LoadYaml

func (c *Config) LoadYaml(filename string, val any) error

LoadYaml scan data to struct.

type Option

type Option func(*Config)

Option config option

func WithEnv

func WithEnv(name string) Option

WithEnv env var

func WithFileType

func WithFileType(fileType string) Option

WithFileType config file type

Jump to

Keyboard shortcuts

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