config

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig() *viper.Viper

func GetEnv

func GetEnv() string

func InitConfigWithPath

func InitConfigWithPath(env string, configPath string)

Types

type BaseConfig

type BaseConfig struct {
	Debug       bool              `mapstructure:"debug,omitempty"`       // debug, default false
	Domain      string            `mapstructure:"domain,omitempty"`      // domain=127.0.0.1:8090
	Databases   []DatabaseConfig  `mapstructure:"databases,omitempty"`   // databases
	Caches      []CacheConfig     `mapstructure:"caches,omitempty"`      // caches
	MemoryCache MemoryCacheConfig `mapstructure:"memoryCache,omitempty"` // caches
}

func GetBaseConfig

func GetBaseConfig() *BaseConfig

type CacheConfig

type CacheConfig struct {
	Alias    string `mapstructure:"alias"`    // alias=forum
	Section  string `mapstructure:"section"`  // section=forum
	Adapter  string `mapstructure:"adapter"`  // adapter=redis
	Host     string `mapstructure:"host"`     // host=127.0.0.1
	Port     int    `mapstructure:"port"`     // port=6379
	Password string `mapstructure:"password"` // password=123456
	DB       int    `mapstructure:"db"`       // db, select db
}

type DatabaseConfig

type DatabaseConfig struct {
	Alias        string `mapstructure:"alias"`        // alias=forum
	Dialect      string `mapstructure:"dialect"`      // dialect=mysql
	Host         string `mapstructure:"host"`         // host=127.0.0.1
	Port         int    `mapstructure:"port"`         // port=3306
	DbName       string `mapstructure:"dbName"`       // name=forum
	Username     string `mapstructure:"username"`     // username=root
	Password     string `mapstructure:"password"`     // password=123456
	MaxIdleConns int    `mapstructure:"maxIdleConns"` // maxIdleConns
	MaxOpenConns int    `mapstructure:"maxOpenConns"` // maxOpenConns
}

type MemoryCacheConfig

type MemoryCacheConfig struct {
	DefaultExpiration int `mapstructure:"defaultExpiration"`
	CleanupInterval   int `mapstructure:"defaultExpiration"`
}

Jump to

Keyboard shortcuts

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