exported func NewMachineSet returns unexported type *machine.machineSet, which can be annoying to use
30 machines []LeasableMachine
31}
32
33func NewMachineSet(flapsClient *flaps.Client, io *iostreams.IOStreams, machines []*fly.Machine) *machineSet { 34 leaseMachines := make([]LeasableMachine, 0)
35 for _, m := range machines {
36 leaseMachines = append(leaseMachines, NewLeasableMachine(flapsClient, io, m))
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")
}