3434// If a new Config is created instead of being parsed from a DSN string,
3535// the NewConfig function should be used, which sets default values.
3636type Config struct {
37+ // non boolean fields
38+
3739 User string // Username
3840 Passwd string // Password (requires User)
3941 Net string // Network (e.g. "tcp", "tcp6", "unix". default: "tcp")
@@ -45,15 +47,15 @@ type Config struct {
4547 Loc * time.Location // Location for time.Time values
4648 MaxAllowedPacket int // Max packet size allowed
4749 ServerPubKey string // Server public key name
48- pubKey * rsa.PublicKey // Server public key
4950 TLSConfig string // TLS configuration name
5051 TLS * tls.Config // TLS configuration, its priority is higher than TLSConfig
51- TimeTruncate time.Duration // Truncate time.Time values to the specified duration
5252 Timeout time.Duration // Dial timeout
5353 ReadTimeout time.Duration // I/O read timeout
5454 WriteTimeout time.Duration // I/O write timeout
5555 Logger Logger // Logger
5656
57+ // boolean fields
58+
5759 AllowAllFiles bool // Allow all files to be used with LOAD DATA LOCAL INFILE
5860 AllowCleartextPasswords bool // Allows the cleartext client side plugin
5961 AllowFallbackToPlaintext bool // Allows fallback to unencrypted connection if server does not support TLS
@@ -66,6 +68,11 @@ type Config struct {
6668 MultiStatements bool // Allow multiple statements in one query
6769 ParseTime bool // Parse time values to time.Time
6870 RejectReadOnly bool // Reject read-only connections
71+
72+ // private fields. new options should be come here
73+
74+ pubKey * rsa.PublicKey // Server public key
75+ timeTruncate time.Duration // Truncate time.Time values to the specified duration
6976}
7077
7178// NewConfig creates a new Config and sets default values.
@@ -263,8 +270,8 @@ func (cfg *Config) FormatDSN() string {
263270 writeDSNParam (& buf , & hasParam , "parseTime" , "true" )
264271 }
265272
266- if cfg .TimeTruncate > 0 {
267- writeDSNParam (& buf , & hasParam , "timeTruncate" , cfg .TimeTruncate .String ())
273+ if cfg .timeTruncate > 0 {
274+ writeDSNParam (& buf , & hasParam , "timeTruncate" , cfg .timeTruncate .String ())
268275 }
269276
270277 if cfg .ReadTimeout > 0 {
@@ -509,7 +516,7 @@ func parseDSNParams(cfg *Config, params string) (err error) {
509516
510517 // time.Time truncation
511518 case "timeTruncate" :
512- cfg .TimeTruncate , err = time .ParseDuration (value )
519+ cfg .timeTruncate , err = time .ParseDuration (value )
513520 if err != nil {
514521 return
515522 }
0 commit comments