From ac51a6a21158a463e8daa8c6b362b2e8671c6b0d Mon Sep 17 00:00:00 2001 From: tiglog Date: Thu, 17 Aug 2023 19:05:46 +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/config.go | 2 +- gconfig/db.go | 33 ++++++++++++++++++--------------- gconfig/param.go | 2 +- go.mod | 1 - go.sum | 1 - 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gconfig/config.go b/gconfig/config.go index 51a5421..aa524ae 100644 --- a/gconfig/config.go +++ b/gconfig/config.go @@ -14,8 +14,8 @@ import ( "git.hexq.cn/tiglog/golib/gfile" - "gopkg.in/yaml.v2" "git.hexq.cn/tiglog/golib/helper" + "gopkg.in/yaml.v3" ) type BaseConfig struct { 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 { diff --git a/go.mod b/go.mod index 46ffe0f..15a9383 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ require ( go.uber.org/zap v1.25.0 golang.org/x/crypto v0.10.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 - gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 14da58e..1d220e3 100644 --- a/go.sum +++ b/go.sum @@ -214,7 +214,6 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=