File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 23
23
tlsConfigRegister map [string ]* tls.Config // Register for custom tls.Configs
24
24
)
25
25
26
- func init () {
27
- tlsConfigRegister = make (map [string ]* tls.Config )
28
- }
29
-
30
26
// RegisterTLSConfig registers a custom tls.Config to be used with sql.Open.
31
27
// Use the key as a value in the DSN where tls=value.
32
28
//
@@ -55,13 +51,19 @@ func RegisterTLSConfig(key string, config *tls.Config) error {
55
51
return fmt .Errorf ("Key '%s' is reserved" , key )
56
52
}
57
53
54
+ if tlsConfigRegister == nil {
55
+ tlsConfigRegister = make (map [string ]* tls.Config )
56
+ }
57
+
58
58
tlsConfigRegister [key ] = config
59
59
return nil
60
60
}
61
61
62
62
// DeregisterTLSConfig removes the tls.Config associated with key.
63
63
func DeregisterTLSConfig (key string ) {
64
- delete (tlsConfigRegister , key )
64
+ if tlsConfigRegister != nil {
65
+ delete (tlsConfigRegister , key )
66
+ }
65
67
}
66
68
67
69
// Returns the bool value of the input.
You can’t perform that action at this time.
0 commit comments