Hacker News new | ask | show | jobs
by asp_hornet 867 days ago
No, you’ve achieved an illusion of that as now your spending hours wasted on discovering where a developer forgot to call NewUsername and instead called Username{“broken”}. I cant see the value in this abstraction in Go.
1 comments

They can’t because value is not exported. They must use the NewUsername function, which forces the validation.

In my opinion, this pattern breaks when the validation must return an error and everything becomes very verbose.

Oh, thats true about it being unexported. I hadn’t considered that.