@@ -8,18 +8,17 @@ import (
88type (
99 // Config struct
1010 Config struct {
11- DB * sql.DB
12- MaxOpenConnections * int
13- MaxIdleConnections * int
14- ConnectionMaxLifetime * time.Duration
11+ MaxOpenConnections int
12+ MaxIdleConnections int
13+ ConnectionMaxLifetime time.Duration
1514 }
1615)
1716
1817// NewConfig creates a new configuration
1918func NewConfig (
20- maxOpenConnections * int ,
21- maxIdleConnections * int ,
22- connectionMaxLifetime * time.Duration ,
19+ maxOpenConnections int ,
20+ maxIdleConnections int ,
21+ connectionMaxLifetime time.Duration ,
2322) * Config {
2423 return & Config {
2524 MaxOpenConnections : maxOpenConnections ,
@@ -45,19 +44,14 @@ func Connect(
4544 }
4645
4746 // Set the maximum open connections
48- if config .MaxOpenConnections != nil {
49- db .SetMaxOpenConns (* config .MaxOpenConnections )
50- }
47+ db .SetMaxOpenConns (config .MaxOpenConnections )
5148
5249 // Set the maximum idle connections
53- if config .MaxIdleConnections != nil {
54- db .SetMaxIdleConns (* config .MaxIdleConnections )
55- }
50+ db .SetMaxIdleConns (config .MaxIdleConnections )
5651
5752 // Set the connection max lifetime
58- if config .ConnectionMaxLifetime != nil {
59- db .SetConnMaxLifetime (* config .ConnectionMaxLifetime )
60- }
53+ db .SetConnMaxLifetime (config .ConnectionMaxLifetime )
54+
6155 return db , nil
6256}
6357
0 commit comments