From ce6ee7dbf79caef07c528594695771cbe5ec527b Mon Sep 17 00:00:00 2001 From: tiglog Date: Thu, 17 Aug 2023 19:01:56 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gconfig/db.go | 33 ++++++++++++++++++--------------- gconfig/param.go | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gconfig/db.go b/gconfig/db.go index bd726d2..91471a5 100644 --- a/gconfig/db.go +++ b/gconfig/db.go @@ -10,12 +10,15 @@ package gconfig import "fmt" type DbConfig struct { - Type string `yaml:"type"` - Host string `yaml:"host"` - Username string `yaml:"user"` - Password string `yaml:"pass"` - Port int `yaml:"port"` - Name string `yaml:"name"` + Type string `yaml:"type"` + Dsn string `yaml:"dsn"` + // Host string `yaml:"host"` + // Username string `yaml:"user"` + // Password string `yaml:"pass"` + // Port int `yaml:"port"` + // Name string `yaml:"name"` + MaxIdle int `yaml:"max_idle"` + MaxOpen int `yaml:"max_open"` } type MongoConfig struct { @@ -27,15 +30,15 @@ type MongoConfig struct { PoolSize int `yaml:"pool_size"` } -func (c *DbConfig) GetUri() string { - switch c.Type { - case "postgres": - return fmt.Sprintf("%s://host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", c.Type, c.Host, c.Port, c.Username, c.Password, c.Name) - case "mysql": - return fmt.Sprintf("%s://%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=Local", c.Type, c.Username, c.Password, c.Host, c.Port, c.Name) - } - return "" -} +// func (c *DbConfig) GetUri() string { +// switch c.Type { +// case "postgres": +// return fmt.Sprintf("%s://host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", c.Type, c.Host, c.Port, c.Username, c.Password, c.Name) +// case "mysql": +// return fmt.Sprintf("%s://%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=Local", c.Type, c.Username, c.Password, c.Host, c.Port, c.Name) +// } +// return "" +// } func (c *MongoConfig) GetUri() string { if c.Host == "" { diff --git a/gconfig/param.go b/gconfig/param.go index bb45210..ad27b4d 100644 --- a/gconfig/param.go +++ b/gconfig/param.go @@ -10,8 +10,8 @@ package gconfig import ( "io/ioutil" - "gopkg.in/yaml.v2" "git.hexq.cn/tiglog/golib/gfile" + "gopkg.in/yaml.v3" ) type ParamConfig struct {