config

package
v0.0.0-...-0194c11 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Vip           = viper.New()
	ConfigFile    = ""
	ServerSetting = new(YamlSetting)
)

Functions

func InitConfig

func InitConfig()

InitConfig reads in config file and ENV variables if set.

Types

type Database

type Database struct {
	DbType       string `yaml:"dbType"`
	Host         string `yaml:"host"`
	Port         int    `yaml:"port"`
	DbName       string `yaml:"dbName"`
	Username     string `yaml:"username"`
	Password     string `yaml:"password"`
	Prefix       string `yaml:"prefix"`
	Charset      string `yaml:"charset"`
	MaxIdleConns int    `yaml:"maxIdleConns"`
	MaxOpenConns int    `yaml:"maxOpenConns"`
	Level        string `yaml:"level"`
	SslMode      string `yaml:"sslMode"`
	TimeZone     string `yaml:"timeZone"`
}

type Log

type Log struct {
	FilePath string `yaml:"filePath"`
	FileName string `yaml:"fileName"`
	Level    string `yaml:"level"`
	Mode     string `yaml:"mode"`
}

type System

type System struct {
	AppName  string `yaml:"appName"`
	HttpAddr string `yaml:"httpAddr"`
	HttpPort string `yaml:"httpPort"`
}

type YamlSetting

type YamlSetting struct {
	System   System   `yaml:"system"`
	Database Database `yaml:"database"`
	Log      Log      `yaml:"log"`
}

func GetConfig

func GetConfig(vip *viper.Viper) *YamlSetting

解析配置文件,反序列化

Jump to

Keyboard shortcuts

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