exported func NewVaultFactory returns unexported type *vault.vaultFactory, which can be annoying to use
17 loginTimeout time.Duration
18}
19
20func NewVaultFactory(sr SecretReader, loginTimeout time.Duration, loggedIn <-chan struct{}, prefix string, prefixes []string, lookupTemplates []*creds.SecretTemplate, sharedPath string) *vaultFactory {21 factory := &vaultFactory{
22 sr: sr,
23 prefix: prefix,
exported func NewCredHubFactory returns unexported type *credhub.credhubFactory, which can be annoying to use
12 prefixes []string
13}
14
15func NewCredHubFactory(logger lager.Logger, credhub *LazyCredhub, prefix string, prefixes []string) *credhubFactory {16 return &credhubFactory{
17 credhub: credhub,
18 logger: logger,
Description
An exported function or method returning a value of an unexported type may be frustrating to use.
In Go, if the function or method starts with a lowercase letter, it is not exported outside the package.
Bad practice
type unexportedType string
func ExportedFunc() *unexportedType {
return &unexportedType("some string")
}
Recommended
type ExportedType string
func ExportedFunc() *ExportedType {
return &ExportedType("some string")
}