chore: 小调整
This commit is contained in:
parent
02b5c78a45
commit
ce6ee7dbf7
@ -11,11 +11,14 @@ import "fmt"
|
|||||||
|
|
||||||
type DbConfig struct {
|
type DbConfig struct {
|
||||||
Type string `yaml:"type"`
|
Type string `yaml:"type"`
|
||||||
Host string `yaml:"host"`
|
Dsn string `yaml:"dsn"`
|
||||||
Username string `yaml:"user"`
|
// Host string `yaml:"host"`
|
||||||
Password string `yaml:"pass"`
|
// Username string `yaml:"user"`
|
||||||
Port int `yaml:"port"`
|
// Password string `yaml:"pass"`
|
||||||
Name string `yaml:"name"`
|
// Port int `yaml:"port"`
|
||||||
|
// Name string `yaml:"name"`
|
||||||
|
MaxIdle int `yaml:"max_idle"`
|
||||||
|
MaxOpen int `yaml:"max_open"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MongoConfig struct {
|
type MongoConfig struct {
|
||||||
@ -27,15 +30,15 @@ type MongoConfig struct {
|
|||||||
PoolSize int `yaml:"pool_size"`
|
PoolSize int `yaml:"pool_size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DbConfig) GetUri() string {
|
// func (c *DbConfig) GetUri() string {
|
||||||
switch c.Type {
|
// switch c.Type {
|
||||||
case "postgres":
|
// 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)
|
// 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":
|
// 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 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 ""
|
// return ""
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (c *MongoConfig) GetUri() string {
|
func (c *MongoConfig) GetUri() string {
|
||||||
if c.Host == "" {
|
if c.Host == "" {
|
||||||
|
@ -10,8 +10,8 @@ package gconfig
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
"git.hexq.cn/tiglog/golib/gfile"
|
"git.hexq.cn/tiglog/golib/gfile"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ParamConfig struct {
|
type ParamConfig struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user