Documentation
¶
Index ¶
- Constants
- func CloseRedisClient() error
- func DefaultDB() (*gorm.DB, error)
- func Get(key string) any
- func GetBool(key string) bool
- func GetFloat64(key string) float64
- func GetInt(key string) int
- func GetLogsDir() string
- func GetString(key string) string
- func GetStringMap(key string) map[string]any
- func GetStringMapString(key string) map[string]string
- func GetStringSlice(key string) []string
- func Init()
- func IsDebugging() bool
- func NewDB(name string) (*gorm.DB, error)
- func NewRedisClient() *redis.Client
- type Config
- type DBConfig
- type LoggerConfig
- type LoggerInstance
- func (l *LoggerInstance) Debug(msg string, fields ...zap.Field)
- func (l *LoggerInstance) Debugf(template string, args ...interface{})
- func (l *LoggerInstance) Error(msg string, fields ...zap.Field)
- func (l *LoggerInstance) Errorf(template string, args ...interface{})
- func (l *LoggerInstance) Info(msg string, fields ...zap.Field)
- func (l *LoggerInstance) Infof(template string, args ...interface{})
- type RedisConfig
- type WebConfig
Constants ¶
View Source
const ( EnvConfigDir = "GO_CONFIG_DIR" // Configuration file directory EnvService = "GO_SERVICE_ENV" // Service environment (local/test/prod) )
Environment variable constants
View Source
const (
EnvLogDir = "GO_LOGS_DIR"
)
Variables ¶
This section is empty.
Functions ¶
func CloseRedisClient ¶
func CloseRedisClient() error
CloseRedisClient closes Redis connection (call on program exit)
func GetFloat64 ¶
func GetLogsDir ¶ added in v0.0.3
func GetLogsDir() string
GetLogsDir gets the log directory path Priority: 1. Environment variable GO_LOG_DIR > 2. logger.path in config file > 3. logs in current directory
func GetStringMap ¶
func GetStringMapString ¶
func GetStringSlice ¶
func IsDebugging ¶
func IsDebugging() bool
func NewRedisClient ¶
Types ¶
type Config ¶
type Config struct {
DebugMode bool `mapstructure:"debug_mode"`
Logger LoggerConfig `mapstructure:"logger"`
Web WebConfig `mapstructure:"web"`
DB map[string]DBConfig `mapstructure:"db"`
Redis RedisConfig `mapstructure:"redis"`
}
type DBConfig ¶
type DBConfig struct {
Driver string `mapstructure:"driver"` // mysql, postgres
Host string `mapstructure:"host"`
Port string `mapstructure:"port"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
Name string `mapstructure:"name"`
MaxIdle int `mapstructure:"max_idle"`
MaxOpen int `mapstructure:"max_open"`
}
type LoggerConfig ¶
type LoggerInstance ¶
type LoggerInstance struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger() *LoggerInstance
func (*LoggerInstance) Debugf ¶
func (l *LoggerInstance) Debugf(template string, args ...interface{})
func (*LoggerInstance) Errorf ¶
func (l *LoggerInstance) Errorf(template string, args ...interface{})
func (*LoggerInstance) Infof ¶
func (l *LoggerInstance) Infof(template string, args ...interface{})
Click to show internal directories.
Click to hide internal directories.