in dialer.go [86:104]
func newKeyGenerator(
k *rsa.PrivateKey, lazy bool, genFunc func() (*rsa.PrivateKey, error),
) (*keyGenerator, error) {
g := &keyGenerator{genFunc: genFunc}
switch {
case k != nil:
// If the caller has provided a key, initialize the key and consume the
// sync.Once now.
g.once.Do(func() { g.key, g.err = k, nil })
case lazy:
// If lazy refresh is enabled, do nothing and wait for the call to
// rsaKey.
default:
// If no key has been provided and lazy refresh isn't enabled, generate
// the key and consume the sync.Once now.
g.once.Do(func() { g.key, g.err = g.genFunc() })
}
return g, g.err
}