Sep 28, 2022
I love this answer, but it creates a dead end in the docs. Godocs won't include the non-exported type and the docs for the non-exported type's exported functions are therefore also inaccessible. If one cares about docs (contextually, one may not) your good advice can be improved by adding an exported interface for the non-exported type. Make the constructor-like function return an interface instead of the type and boom... your type can be instantiated only as intended and there will also be no dead end in the docs.