configHelper

package
v1.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetViper

func GetViper(data *configStruct.ViperConfig) (viperData *viper.Viper, err error)

GetViper 获取viper配置对象

func LoadConfig

func LoadConfig(viperData *viper.Viper, target interface{}) error

LoadConfig 将配置文件内容解码到目标结构体。 - viperData 允许复用已配置的 viper 实例;传 nil 时会通过 data 创建新的实例。 - data 指定配置文件信息;当 viperData 非 nil 时可为 nil。 返回使用中的 viper 实例,便于后续继续读取其它键。

func SimpleLoadConfig

func SimpleLoadConfig(data *configStruct.ViperConfig, target interface{}) error

func SimpleLoadHTTPConfig

func SimpleLoadHTTPConfig(viperData *viper.Viper) (*configStruct.HttpConfig, error)

SimpleLoadHTTPConfig 简单读取http配置

func SimpleLoadRepoConfig

func SimpleLoadRepoConfig(viperData *viper.Viper, dbType string) (*configStruct.RepoConfig, error)

SimpleLoadRepoConfig 数据仓库配置

Types

type AppConfig

type AppConfig struct {
	Env  string `mapstructure:"env" default:"dev"`
	HTTP struct {
		IP   string `mapstructure:"ip" default:"0.0.0.0"`
		Port string `mapstructure:"port" default:"8080"`
	} `mapstructure:"http"`
}

AppConfig 例子

Jump to

Keyboard shortcuts

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