package db import ( "time" ) // Config config type Config struct { Driver string DNS string MaxOpenConns int MaxIdle int MaxIdleTime time.Duration MaxLifeTime time.Duration } // SetConfig set func SetConfig(cfg Config) { config.Driver = cfg.Driver config.DNS = cfg.DNS config.MaxOpenConns = cfg.MaxOpenConns config.MaxIdle = cfg.MaxIdle config.MaxIdleTime = cfg.MaxIdleTime * time.Second config.MaxLifeTime = cfg.MaxLifeTime * time.Second defaultDB = &DB{Driver: config.Driver} }