gconfig

package
v0.3.6-gz Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbServer

type DbServer struct {
	Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
	Pgsql Pgsql `mapstructure:"pgsql" json:"pgsql" yaml:"pgsql"`
}

type DbSys

type DbSys struct {
	// DbType 数据库类型:mysql(默认)|sqlite|sqlserver|postgresql
	DbType string `mapstructure:"db-type" json:"db-type" yaml:"db-type"`
}

type DsnProvider

type DsnProvider interface {
	Dsn() string
}

type GeneralDB

type GeneralDB struct {
	Prefix         string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
	Port           string `mapstructure:"port" json:"port" yaml:"port"`
	Config         string `mapstructure:"config" json:"config" yaml:"config"`       // 高级配置
	Dbname         string `mapstructure:"db-name" json:"db-name" yaml:"db-name"`    // 数据库名
	Username       string `mapstructure:"username" json:"username" yaml:"username"` // 数据库密码
	Password       string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码
	Path           string `mapstructure:"path" json:"path" yaml:"path"`
	Engine         string `mapstructure:"engine" json:"engine" yaml:"engine" default:"InnoDB"`        //数据库引擎,默认InnoDB
	LogMode        string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"`                   // 是否开启Gorm全局日志
	MaxIdleConns   int    `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"` // 空闲中的最大连接数
	MaxOpenConns   int    `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
	Singular       bool   `mapstructure:"singular" json:"singular" yaml:"singular"`                   //是否开启全局禁用复数,true表示开启
	LogType        string `mapstructure:"log-type" json:"log-type" yaml:"log-type"`                   // default:console, optional[console, zap, go-zero]
	Migration      bool   `mapstructure:"migration" json:"migration" yaml:"migration"`
	MigrationPath  string `mapstructure:"migration-path" json:"migration-path" yaml:"migration-path"` // migration-path
	MigrationTable string `mapstructure:"migration-table" json:"migration-table" yaml:"migration-table"`
}

GeneralDB 也被 Pgsql 和 Mysql 原样使用

type Mysql

type Mysql struct {
	GeneralDB `yaml:",inline" mapstructure:",squash"`
}

func (*Mysql) Dsn

func (m *Mysql) Dsn() string

func (*Mysql) GetLogMode

func (m *Mysql) GetLogMode() string

type Pgsql

type Pgsql struct {
	GeneralDB `yaml:",inline" mapstructure:",squash"`
}

func (*Pgsql) Dsn

func (p *Pgsql) Dsn() string

Dsn 基于配置文件获取 dsn

func (*Pgsql) GetLogMode

func (m *Pgsql) GetLogMode() string

func (*Pgsql) LinkDsn

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

LinkDsn 根据 dbname 生成 dsn

Jump to

Keyboard shortcuts

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