Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My Go is rusty, do you mean not exporting the type "Username" (ie username) to avoid default constructor usage?


In 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: