option

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfigPath

func AddConfigPath(path string)

AddConfigPath 添加配置文件目录

func HomeDir

func HomeDir() string

func SetConfigFileType

func SetConfigFileType(t string)

SetConfigFileType 配置文件类型

func SetConfigName

func SetConfigName(n string)

SetConfigName 配置名称

Types

type DatabaseOption

type DatabaseOption struct {
	Host               string `default:"localhost"`
	Port               int    `default:"3306"`
	Username           string
	Password           string
	Database           string
	MaxOpenConnections int `default:"5" yaml:"max_open_connections" json:"max_open_connections"`
	MaxIdleConnections int `default:"3" yaml:"max_idle_connections" json:"max_idle_connections"`
}

DatabaseOption mysql数据库配置

type LoggerOption

type LoggerOption struct {
	Level      string `default:"info"`
	Name       string
	Filename   string
	MaxSize    int  `default:"100" yaml:"max_size,omitempty" json:"max_size,omitempty"`
	MaxAge     int  `default:"7" yaml:"max_age,omitempty" json:"max_age,omitempty"`
	MaxBackups int  `default:"30" yaml:"max_backups,omitempty" json:"max_backups,omitempty"`
	LocalTime  bool `default:"true" yaml:"local_time,omitempty" json:"local_time,omitempty"`
	Compress   bool
}

LoggerOption 日志配置模块

type Option

type Option struct {
	Description string
	Logger      LoggerOption
	Router      RouterOption
	Database    DatabaseOption
}

Option 配置入口

func LoadConfig

func LoadConfig() *Option

type RouterOption

type RouterOption struct {
	Port            int  `default:"8080"`
	MergeLog        bool `default:"false" yaml:"merge_log" json:"merge_log"`
	DumpResponse    bool `default:"false" yaml:"dump_response" json:"dump_response"`
	LogStackIfPanic bool `default:"true" yaml:"log_stack_if_panic" json:"log_stack_if_panic"`
}

RouterOption 服务运行时配置

Jump to

Keyboard shortcuts

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