config

package
v0.0.0-...-d340b99 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug   bool         `toml:"debug"`
	LogPath string       `toml:"log_path"`
	HTTP    *HTTP        `toml:"http"`
	DB      *MySQLConfig `toml:"db"`
}

Config 配置

func GetCfg

func GetCfg() *Config

GetCfg 获取配置

func LoadConfig

func LoadConfig(cfgPath string) (*Config, error)

LoadConfig 读取配置

type HTTP

type HTTP struct {
	Address               string   `toml:"address"`
	Port                  int      `toml:"port"`
	TLSEnable             bool     `toml:"tls_enable"`               // 是否启用tls连接
	TLSConfig             *HTTPTls `toml:"tls_config"`               // 启用tls时必须配置此内容
	TLSEncryptEnable      bool     `toml:"tls_encrypt_enable"`       // 是否启用 Let's Encrypt tls
	TLSEncryptDomainNames []string `toml:"tls_encrypt_domain_names"` // 启用 Let's Encrypt 时的域名列表
}

HTTP http 件套配置

type HTTPTls

type HTTPTls struct {
	CertFile string `toml:"cert_file"`
	KeyFile  string `toml:"key_file"`
}

HTTPTls http tls配置

type MySQLConfig

type MySQLConfig struct {
	Debug        bool   `toml:"debug"`          // 是否调试模式
	Address      string `toml:"address"`        // 数据库连接地址
	Port         int    `toml:"port"`           // 数据库端口
	MaxIdleConns int    `toml:"max_idle_conns"` // 连接池最大连接数
	MaxOpenConns int    `toml:"max_open_conns"` // 默认打开连接数
	User         string `toml:"user"`           // 数据库用户名
	Passwd       string `toml:"passwd"`         // 数据库密码
	DbName       string `toml:"db_name"`        // 数据库名
}

MySQLConfig 数据库配置

Jump to

Keyboard shortcuts

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