22 lines
687 B
Go
22 lines
687 B
Go
|
package config
|
||
|
|
||
|
type Pgsql struct {
|
||
|
GeneralDB `yaml:",inline" mapstructure:",squash"`
|
||
|
}
|
||
|
|
||
|
// Dsn 基于配置文件获取 dsn
|
||
|
// Author [SliverHorn](https://github.com/SliverHorn)
|
||
|
func (p *Pgsql) Dsn() string {
|
||
|
return "host=" + p.Path + " user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config
|
||
|
}
|
||
|
|
||
|
// LinkDsn 根据 dbname 生成 dsn
|
||
|
// Author [SliverHorn](https://github.com/SliverHorn)
|
||
|
func (p *Pgsql) LinkDsn(dbname string) string {
|
||
|
return "host=" + p.Path + " user=" + p.Username + " password=" + p.Password + " dbname=" + dbname + " port=" + p.Port + " " + p.Config
|
||
|
}
|
||
|
|
||
|
func (m *Pgsql) GetLogMode() string {
|
||
|
return m.LogMode
|
||
|
}
|