config

package
v0.0.0-...-9528f6d Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var App = &AppConfig{
	Name:     config.GetString("app.name", "MIN"),
	Addr:     config.GetString("app.addr", "127.0.0.1"),
	Port:     config.GetInt("app.port", 3000),
	Debug:    config.GetBool("app.debug", false),
	Locale:   config.GetString("app.locale", "zh"),
	LangPath: "locales",
}
View Source
var Cache = &CacheConfig{
	Driver:   "redis",
	Prefix:   str.ToSnakeCase(App.Name) + ":cache:",
	Database: 1,
}
View Source
var Database = &DatabaseConfig{
	Driver:    config.GetString("database.driver", "mysql"),
	Host:      config.GetString("database.host", "127.0.0.1"),
	Port:      config.GetInt("database.port", 3306),
	Database:  config.GetString("database.database"),
	User:      config.GetString("database.user"),
	Password:  config.GetString("database.password"),
	Charset:   config.GetString("database.charset", "utf8mb4"),
	Collation: config.GetString("database.collation", "utf8mb4_unicode_ci"),
	Timeout:   config.GetString("database.timeout", "5s"),
	Debug:     config.GetBool("database.debug", false),
}
View Source
var Jwt = &JwtConfig{
	SigningKey: "jwtClaims",
	Secret:     config.GetString("jwt.secret"),
	TTL:        time.Hour * 1,
}
View Source
var Log = &LogConfig{
	Driver: config.GetString("log.driver", "file"),
	Path:   config.GetString("log.path", "logs/"+str.ToSnakeCase(App.Name)+".log"),
	Level:  config.GetString("log.level", "info"),
	Daily:  config.GetBool("log.daily", true),
	Days:   config.GetInt("log.days", 15),
}
View Source
var Redis = &RedisConfig{
	Host:     config.GetString("redis.host", "127.0.0.1"),
	Port:     config.GetInt("redis.port", 6379),
	Password: config.GetString("redis.password", ""),
	Database: 0,
}

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Name     string
	Addr     string
	Port     int
	Debug    bool
	Locale   string // Supports "en", "zh"
	LangPath string
}

type CacheConfig

type CacheConfig struct {
	Driver   string
	Prefix   string
	Database int
}

type DatabaseConfig

type DatabaseConfig struct {
	Driver    string
	Host      string
	Port      int
	Database  string
	User      string
	Password  string
	Charset   string
	Collation string
	Timeout   string // Dial Timeout, See https://github.com/go-sql-driver/mysql#timeout
	Debug     bool
}

type JwtConfig

type JwtConfig struct {
	SigningKey string // The name of the key used to sign the token in the request context
	Secret     string
	TTL        time.Duration
}

type LogConfig

type LogConfig struct {
	Driver string // Supports: "file"
	Path   string
	Level  string // Supports: "debug", "info", "warn", "error", "fatal"
	Daily  bool   // Supported driver: "file", Whether to generate a new log file every day
	Days   int    // Supported driver: "file", The number of days to keep the log file
}

type RedisConfig

type RedisConfig struct {
	Host     string
	Port     int
	Password string
	Database int
}

Jump to

Keyboard shortcuts

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