4 ms·
My Go is rusty, do you mean not exporting the type "Username" (ie username) to avoid default constructor usage?
by swah 3y ago
My Go is rusty, do you mean not exporting the type "Username" (ie username) to avoid default constructor usage?
- mtlynch 3y agoIn Go, capitalized identifiers are exported, whereas lowercase identifiers are not. In the example I gave above, clients outside of the package can instantiate Username, but they can't access its "value" member, so the only way they could get a populated Username instance is by calling NewUsername.