config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: Apache-2.0 Imports: 1 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 {
	System *System              `mapstructure:"system" json:"system" yaml:"system"`
	Logger *logger.LoggerConfig `mapstructure:"logger" json:"logger" yaml:"logger"`

	Mysql  Mysql  `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
	Pgsql  Pgsql  `mapstructure:"pgsql" json:"pgsql" yaml:"pgsql"`
	Sqlite Sqlite `mapstructure:"sqlite" json:"sqlite" yaml:"sqlite"`
}

type Mysql added in v1.1.0

type Mysql struct {
	Path         string `mapstructure:"path" json:"path" yaml:"path"`                             // 服务器地址
	Port         string `mapstructure:"port" json:"port" yaml:"port"`                             // 端口
	Config       string `mapstructure:"config" json:"config" yaml:"config"`                       // 高级配置
	Dbname       string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`                     // 数据库名
	Username     string `mapstructure:"username" json:"username" yaml:"username"`                 // 数据库用户名
	Password     string `mapstructure:"password" json:"password" yaml:"password"`                 // 数据库密码
	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数
	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
	LogMode      string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`                  // 是否开启Gorm全局日志
	LogZap       bool   `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"`                     // 是否通过zap写入日志文件
}

func (*Mysql) Dsn added in v1.1.0

func (m *Mysql) Dsn() string

type Pgsql added in v1.1.0

type Pgsql struct {
	Path         string `mapstructure:"path" json:"path" yaml:"path"`                             // 服务器地址:端口
	Port         string `mapstructure:"port" json:"port" yaml:"port"`                             //:端口
	Config       string `mapstructure:"config" json:"config" yaml:"config"`                       // 高级配置
	Dbname       string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`                     // 数据库名
	Username     string `mapstructure:"username" json:"username" yaml:"username"`                 // 数据库用户名
	Password     string `mapstructure:"password" json:"password" yaml:"password"`                 // 数据库密码
	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"` // 空闲中的最大连接数
	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
	LogMode      string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`                  // 是否开启Gorm全局日志
	LogZap       bool   `mapstructure:"log-zap" json:"logZap" yaml:"log-zap"`                     // 是否通过zap写入日志文件
}

func (*Pgsql) Dsn added in v1.1.0

func (p *Pgsql) Dsn() string

Dsn 基于配置文件获取 dsn Author [SliverHorn](https://github.com/SliverHorn)

func (*Pgsql) LinkDsn added in v1.1.0

func (p *Pgsql) LinkDsn(dbname string) string

LinkDsn 根据 dbname 生成 dsn Author [SliverHorn](https://github.com/SliverHorn)

type Sqlite added in v1.1.0

type Sqlite struct {
	Path   string `mapstructure:"path" json:"path" yaml:"path"`
	Memory bool   `mapstructure:"memory" json:"memory" yaml:"memory"`
}

func (*Sqlite) Dsn added in v1.1.0

func (p *Sqlite) Dsn() string

type System

type System struct {
	Port string `mapstructure:"port" json:"port" yaml:"port"`
	Mode string `mapstructure:"mode" json:"mode" yaml:"mode"`

	// 数据库类型:sqlite|sqlserver|postgresql|mysql
	DbType string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`

	StaticPath     string `mapstructure:"static-path" json:"staticPath" yaml:"static-path"`
	EnableAuditLog bool   `mapstructure:"enable-audit-log" json:"enableAuditLog" yaml:"enable-audit-log"`
}

Jump to

Keyboard shortcuts

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