viper

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 4 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 {
	Debug             bool
	Watch             bool
	ConfigName        string
	ConfigFile        string
	ConfigType        string
	ConfigPermissions os.FileMode
	EnvPrefix         string
	RemoteProvider    []RemoteProvider
	AllowEmptyEnv     bool
	IniLoadOptions    ini.LoadOptions
	EnvVars           []string
}

全局变量,只一个实例,只提供config

func (*Config) AfterInject

func (c *Config) AfterInject()

AfterInject calls Init after config fields are populated.

func (*Config) BeforeInject

func (c *Config) BeforeInject()

BeforeInject is a no-op satisfying the Config interface.

func (*Config) Build

func (c *Config) Build() (*viper.Viper, error)

Build creates and configures a new Viper instance (remote or local) based on the config fields.

func (*Config) Init

func (c *Config) Init() *Config

Init sets the default config type to "toml" if not specified.

type RemoteProvider

type RemoteProvider struct {
	Provider      string
	Endpoint      string
	Path          string
	SecretKeyring string
}

type Viper

type Viper struct {
	*viper.Viper
	Conf Config
}

Viper is a DaoField wrapper around viper.Viper. Prefer using the global Viper instance instead.

func (*Viper) Close

func (v *Viper) Close() error

Close is intentionally a no-op (the Viper type has no teardown); prefer using the global Viper instance.

func (*Viper) Config

func (v *Viper) Config() any

Config returns the embedded Conf as the configuration for injection.

func (*Viper) Init

func (v *Viper) Init() error

Init creates and stores the Viper instance.

Jump to

Keyboard shortcuts

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