yaml

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Yaml    = "yaml.yaml"     // Production Config File (Normal)
	YamlEnc = "yaml.enc.yaml" // Production Config File (Encrypt)
	YamlDev = "yaml.dev.yaml" // Development Config File
	Debug   = "debug"         // Development Mode
	Release = "release"       // Release Production Mode
)

Variables

View Source
var (
	EnvMode           string = ""    // Const[ Debug, Release, "" ]
	LockConfigFile    string = ""    // Const[ Yaml, YamlEnc, YamlDev, "" ]
	EncryptConfigYaml bool   = false // Encrypt Config Files
	EncryptSecretKey  string = ""    // Please change your key
)
View Source
var (
	COMMON     = &CONFIG.Common
	MYSQL      = &CONFIG.Mysql
	PGSQL      = &CONFIG.Pgsql
	JWT        = &CONFIG.Jwt
	REDIS      = &CONFIG.Redis
	SQLITE     = &CONFIG.SQLite
	ZAP        = &CONFIG.Zap
	REQUESTLOG = &CONFIG.RequestLog
	WEBSOCKET  = &CONFIG.WebSocket
)
View Source
var CONFIG loader

Functions

This section is empty.

Types

type Common

type Common struct {
	HttpPort        string `mapstructure:"http_port" json:"http_port" yaml:"http_port"`       // Application http port
	UploadPath      string `mapstructure:"upload_path" json:"upload_path" yaml:"upload_path"` // Upload file directory
	HotReloadConfig bool   `mapstructure:"hot_reload_config" json:"hot_reload_config" yaml:"hot_reload_config"`
	RootPath        string // Application root
	SystemVersion   string
}

type Jwt

type Jwt struct {
	SigningKey  string `mapstructure:"signing_key" json:"signing_key" yaml:"signing_key"`    // jwt signature
	ExpiresTime string `mapstructure:"expires_time" json:"expires_time" yaml:"expires_time"` // expiration time
	BufferTime  string `mapstructure:"buffer_time" json:"buffer_time" yaml:"buffer_time"`    // buffer time
	Issuer      string `mapstructure:"issuer" json:"issuer" yaml:"issuer"`                   // issuer
}

type Mysql

type Mysql struct {
	Enable      bool    `mapstructure:"enable" json:"enable" yaml:"enable"`
	Path        string  `mapstructure:"path" json:"path" yaml:"path"`
	Port        string  `mapstructure:"port" json:"port" yaml:"port"`
	Config      string  `mapstructure:"yaml" json:"yaml" yaml:"yaml"`
	Dbname      string  `mapstructure:"dbname" json:"dbname" yaml:"dbname"`
	Username    string  `mapstructure:"username" json:"username" yaml:"username"`
	Password    string  `mapstructure:"password" json:"password" yaml:"password"`
	MaxIdleCons int     `mapstructure:"max_idle_cons" json:"max_idle_cons" yaml:"max_idle_cons"`
	MaxOpenCons int     `mapstructure:"max_open_cons" json:"max_open_cons" yaml:"max_open_cons"`
	LogEnable   bool    `mapstructure:"log_enable" json:"log_enable" yaml:"log_enable"`
	LogLevel    string  `mapstructure:"log_level" json:"log_level" yaml:"log_level" validate:"oneof=debug info warn error panic fatal"`
	LogToFile   bool    `mapstructure:"log_to_file" json:"log_to_file" yaml:"log_to_file"`
	ListDb      []Mysql `mapstructure:"list_db" json:"list_db" yaml:"list_db"`
}

func (*Mysql) Dsn

func (m *Mysql) Dsn() string

type Pgsql

type Pgsql struct {
	Enable      bool   `mapstructure:"enable" json:"enable" yaml:"enable"`
	Path        string `mapstructure:"path" json:"path" yaml:"path"`
	Port        string `mapstructure:"port" json:"port" yaml:"port"`
	Config      string `mapstructure:"yaml" json:"yaml" yaml:"yaml"`
	Dbname      string `mapstructure:"dbname" json:"dbname" yaml:"dbname"`
	Username    string `mapstructure:"username" json:"username" yaml:"username"`
	Password    string `mapstructure:"password" json:"password" yaml:"password"`
	Schema      string `mapstructure:"schema" json:"schema" yaml:"schema"`
	MaxIdleCons int    `mapstructure:"max_idle_cons" json:"max_idle_cons" yaml:"max_idle_cons"`
	MaxOpenCons int    `mapstructure:"max_open_cons" json:"max_open_cons" yaml:"max_open_cons"`
	LogEnable   bool   `mapstructure:"log_enable" json:"log_enable" yaml:"log_enable"`
	LogLevel    string `mapstructure:"log_level" json:"log_level" yaml:"log_level" validate:"oneof=debug info warn error panic fatal"`
	LogToFile   string `mapstructure:"log_to_file" json:"log_to_file" yaml:"log_to_file"`
}

func (*Pgsql) Dsn

func (p *Pgsql) Dsn() string

func (*Pgsql) TableName

func (p *Pgsql) TableName(table string) string

type Redis

type Redis struct {
	Enable   bool   `mapstructure:"enable" json:"enable" yaml:"enable"`
	DB       int    `mapstructure:"db" json:"db" yaml:"db"`       // Default database 0
	Addr     string `mapstructure:"addr" json:"addr" yaml:"addr"` // address:port
	Password string `mapstructure:"password" json:"password" yaml:"password"`
}

type RequestLog

type RequestLog struct {
	Enable          bool   `mapstructure:"enable" json:"enable" yaml:"enable"`
	ClientIP        bool   `mapstructure:"client_ip" json:"client_ip" yaml:"client_ip"`
	TimeStampFormat string `mapstructure:"time_stamp_format" json:"time_stamp_format" yaml:"time_stamp_format"`
	Method          bool   `mapstructure:"method" json:"method" yaml:"method"`
	Path            bool   `mapstructure:"path" json:"path" yaml:"path"`
	RequestProto    bool   `mapstructure:"request_proto" json:"request_proto" yaml:"request_proto"`
	StatusCode      bool   `mapstructure:"status_code" json:"status_code" yaml:"status_code"`
	Latency         bool   `mapstructure:"latency" json:"latency" yaml:"latency"`
	UserAgent       bool   `mapstructure:"user_agent" json:"user_agent" yaml:"user_agent"`
	ErrorMessage    bool   `mapstructure:"error_message" json:"error_message" yaml:"error_message"`
}

type SQLite

type SQLite struct {
	Enable    bool   `mapstructure:"enable" json:"enable" yaml:"enable"`
	Path      string `mapstructure:"path" json:"path" yaml:"path"`
	LogEnable bool   `mapstructure:"log_enable" json:"log_enable" yaml:"log_enable"`
	LogLevel  string `mapstructure:"log_level" json:"log_level" yaml:"log_level" validate:"oneof=debug info warn error panic fatal"`
	LogToFile string `mapstructure:"log_to_file" json:"log_to_file" yaml:"log_to_file"`
}

type WebSocket

type WebSocket struct {
	Enable          bool   `mapstructure:"enable" json:"enable" yaml:"enable"`
	WSPort          string `mapstructure:"ws_port" json:"ws_port" yaml:"ws_port"`
	Path            string `mapstructure:"path" json:"path" yaml:"path"`
	ReadBufferSize  int    `mapstructure:"read_buffer_size" json:"read_buffer_size" yaml:"read_buffer_size"`
	WriteBufferSize int    `mapstructure:"write_buffer_size" json:"write_buffer_size" yaml:"write_buffer_size"`
	Log             bool   `mapstructure:"log" json:"log" yaml:"log"`
}

type Zap

type Zap struct {
	Level         string `mapstructure:"level" json:"level" yaml:"level"`                                                     // Log level
	Prefix        string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`                                                  // Log prefix
	OutputMode    string `mapstructure:"output_mode" json:"output_mode" yaml:"output_mode" validate:"oneof=console file any"` // Log output mode [console, file, any]
	Format        string `mapstructure:"format" json:"format" yaml:"format"  validate:"oneof=console json"`                   // Log format [console, json]
	Director      string `mapstructure:"director" json:"director" yaml:"director"`                                            // Log folder
	EncodeLevel   string `mapstructure:"encode_level" json:"encode_level" yaml:"encode_level"`
	StacktraceKey string `mapstructure:"stacktrace_key" json:"stacktrace_key" yaml:"stacktrace_key"`
	MaxAge        int    `mapstructure:"max_age" json:"max_age" yaml:"max_age"`                                           // Old log files max day
	MaxSize       int    `mapstructure:"max_size" json:"max_size" yaml:"max_size"`                                        // Size of a single log file(单位M)
	MaxBackups    int    `mapstructure:"max_backups" json:"max_backups" yaml:"max_backups"`                               // Old log files max num
	ShowLine      bool   `mapstructure:"show_line" json:"show_line" yaml:"show_line"`                                     // display line
	LoggerOutput  int    `mapstructure:"logger_output" json:"logger_output" yaml:"logger_output"  validate:"oneof=0 1 2"` // [0,1,2] 0.Console prints and writes files | 1.writes files | 2.Console prints
}

Jump to

Keyboard shortcuts

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