config

package
v0.0.0-...-588ec63 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CfgFileFlag string

Functions

func AllSettings

func AllSettings() map[string]interface{}

func BindEnv

func BindEnv()

func Get

func Get(key string) interface{}

func GetBool

func GetBool(key string) bool

func GetDuration

func GetDuration(key string) time.Duration

func GetFloat64

func GetFloat64(key string) float64

func GetInt

func GetInt(key string) int

func GetIntSlice

func GetIntSlice(key string) []int

func GetString

func GetString(key string) string

func GetStringMap

func GetStringMap(key string) map[string]interface{}

func GetStringMapString

func GetStringMapString(key string) map[string]string

func GetStringSlice

func GetStringSlice(key string) []string

func GetTime

func GetTime(key string) time.Time

func IsSet

func IsSet(key string) bool

func SetDefaultConfig

func SetDefaultConfig()

Types

type Config

type Config struct {
	Server ConfigServer `mapstructure:"server"`
	DB     ConfigDB     `mapstructure:"db"`
	Logger ConfigLogger `mapstructure:"logger"`
	JWT    ConfigJWT    `mapstructure:"jwt"`
}
var ServerConfig *Config

func NewConfig

func NewConfig() *Config

func (*Config) ApplyConfig

func (c *Config) ApplyConfig()

ApplyConfig reads and applies all configurations in the following order of priority: 1. Command line flags 2. Environment variables 3. Config file 4. Default values If a config file is specified, it will be read from the specified path Otherwise, the config file will be read from the default path

type ConfigDB

type ConfigDB struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Member   string `mapstructure:"member"`
	Password string `mapstructure:"password"`
	DBName   string `mapstructure:"dbname"`
	SSLMode  string `mapstructure:"sslmode"`
}

type ConfigJWT

type ConfigJWT struct {
	Secret     string `mapstructure:"secret"`
	Expiration int    `mapstructure:"expiration"`
}

type ConfigLogger

type ConfigLogger struct {
	Level string `mapstructure:"level"`
}

type ConfigServer

type ConfigServer struct {
	Address string `mapstructure:"address"`
	Port    string `mapstructure:"port"`
}

Jump to

Keyboard shortcuts

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