config_mysql.go 613 B

1234567891011121314151617181920212223242526
  1. package config
  2. var (
  3. _mysqlConfig *MySQLConfig
  4. )
  5. type MySQLConfig struct {
  6. UserName string `yaml:"user,omitempty"`
  7. Pwd string `yaml:"pwd,omitempty"`
  8. Host string `yaml:"host,omitempty"`
  9. Port int `yaml:"port,omitempty"`
  10. DB string `yaml:"name,omitempty"`
  11. CharSet string `yaml:"character,omitempty"`
  12. MaxIdleCon int `yaml:"max_idle_con,omitempty"`
  13. MaxOpenCon int `yaml:"max_open_con,omitempty"`
  14. }
  15. func InitMySQL(path string) {
  16. var config MySQLConfig
  17. readConfig(path, &config)
  18. _mysqlConfig = &config
  19. }
  20. func GetMySQLConfig() MySQLConfig {
  21. return *_mysqlConfig
  22. }