✨ init project
This commit is contained in:
17
config/gorm_pgsql.go
Normal file
17
config/gorm_pgsql.go
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user