3 ms·
The problem there is that you lose the guarantee that the parser validated the string value. A caller can just say: // This is returning an error for some
by mtlynch 3y ago
The problem there is that you lose the guarantee that the parser validated the string value.
A caller can just say:
// This is returning an error for some reason, so let's do it directly.
// username, err := parsers.NewUsername(raw)
username := parsers.Username(raw)
You also get implicit conversions in ways you probably don't want:
var u Username
u = "<hello>" // Implicitly converts from string to Username
- costco 3y agoThat's true I did not think of that.