exported func SprintfAssertionLoggerFn returns unexported type assertions.assertionLoggerFn, which can be annoying to use
24
25type assertionLoggerFn func(string, ...interface{})
26
27func SprintfAssertionLoggerFn(s *string) assertionLoggerFn { 28 return func(ef string, eargs ...interface{}) {
29 *s = fmt.Sprintf(ef, eargs...)
30 }
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")
}