3 ms·
> first of all, struct creation is supposed to be light-weight. Non-nullable pointers don't make struct creation any more expensive. > You can provide a "func
by masklinn 8y ago
> first of all, struct creation is supposed to be light-weight.
Non-nullable pointers don't make struct creation any more expensive.
> You can provide a "function constructor", which is simply a function that returns SomeStruct or * SomeStruct, but it is not required, nor can you forbid the free-form constructor.
You can have an exported function returning a non-exported type. This restricts the "freeform" constructor to the package's internal's. It severely limits the caller's ability to use it (unless you also provide an interface to work with), but it's there.