func (cfg *Config) Source() string {
	pwd := cfg.Password
	if pwd != "" {
		pwd = ":" + pwd
	}
	port := cfg.Port
	if port == 0 {
		port = 3306
	}
	return fmt.Sprintf("%s%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=Local&interpolateParams=true", cfg.Username, pwd, cfg.Host, port, cfg.Database)
}
Source returns the mysql connection string.
package mysql
import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/henrylee2cn/cfgo"
)
type Config struct {
	Database string
	Username string
	Password string
	Host     string
	Port     int
	MaxIdleConns int `yaml:"max_idle_conns"`
	MaxOpenConns int `yaml:"max_open_conns"`
	ConnMaxLifetime int64 `yaml:"conn_max_lifetime"`
	NoCache bool `yaml:"no_cache"`
	init bool
}
var configs = make(map[string]*Config)
func ReadConfig(configSection string) (*Config, error) {
	conf, ok := configs[configSection]
	if ok {
		return conf, nil
	}
	conf = NewConfig()
	err := cfgo.Reg(configSection, conf)
	if err == nil {
		configs[configSection] = conf
		return conf, nil
	} else {
		return nil, err
	}
}
func NewConfig() *Config {
	return &Config{
		Host:     "127.0.0.1",
		Port:     3306,
		Username: "root",
		Database: "test",
	}
}