config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 7 Imported by: 1

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 interface{}) error

Load alias for config func.

func LoadJson

func LoadJson(filename string, val interface{}) error

LoadJson alias for config func.

func LoadToml

func LoadToml(filename string, val interface{}) 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 interface{}) 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 interface{}) error

Load scan data to struct.

func (*Config) LoadJson

func (c *Config) LoadJson(filename string, val interface{}) error

LoadJson scan data to struct.

func (*Config) LoadToml

func (c *Config) LoadToml(filename string, val interface{}) 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 interface{}) 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