MCPcopy
hub / github.com/jackc/pgx / Copy

Method Copy

pgconn/config.go:156–178  ·  view source on GitHub ↗

Copy returns a deep copy of the config that is safe to use and modify. The only exception is the TLSConfig field: according to the tls.Config docs it must not be modified after creation.

()

Source from the content-addressed store, hash-verified

154// The only exception is the TLSConfig field:
155// according to the tls.Config docs it must not be modified after creation.
156func (c *Config) Copy() *Config {
157 newConf := new(Config)
158 *newConf = *c
159 if newConf.TLSConfig != nil {
160 newConf.TLSConfig = c.TLSConfig.Clone()
161 }
162 if newConf.RuntimeParams != nil {
163 newConf.RuntimeParams = make(map[string]string, len(c.RuntimeParams))
164 maps.Copy(newConf.RuntimeParams, c.RuntimeParams)
165 }
166 if newConf.Fallbacks != nil {
167 newConf.Fallbacks = make([]*FallbackConfig, len(c.Fallbacks))
168 for i, fallback := range c.Fallbacks {
169 newFallback := new(FallbackConfig)
170 *newFallback = *fallback
171 if newFallback.TLSConfig != nil {
172 newFallback.TLSConfig = fallback.TLSConfig.Clone()
173 }
174 newConf.Fallbacks[i] = newFallback
175 }
176 }
177 return newConf
178}
179
180// FallbackConfig is additional settings to attempt a connection with when the primary Config fails to establish a
181// network connection. It is used for TLS fallback such as sslmode=prefer and high availability (HA) connections.

Callers 5

mergeSettingsFunction · 0.45
connectOneFunction · 0.45

Calls

no outgoing calls