config

package
v0.0.0-...-eb6e4a7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(filename string, val any, hook func(v *viper.Viper)) error

Load alias for config func.

func LoadWithType

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

LoadWithType load conf by file type.

Types

type Config

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

Config conf struct.

func New

func New(opts ...Option) *Config

New create a config instance.

func (*Config) Load

func (c *Config) Load(filename string, val any, hook func(v *viper.Viper)) error

Load scan data to struct.

func (*Config) LoadWithType

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

LoadWithType load conf by file type.

type Option

type Option func(*Config)

func WithDir

func WithDir(dir string) Option

func WithEnvPrefix

func WithEnvPrefix(prefix string) Option

func WithFileTypeJson

func WithFileTypeJson() Option

func WithFileTypeToml

func WithFileTypeToml() Option

func WithFileTypeYaml

func WithFileTypeYaml() Option

Jump to

Keyboard shortcuts

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