logoalt Hacker News

semiquaveryesterday at 11:33 PM2 repliesview on HN

Doesn’t the type name uuid.UUID violate go’s style guide for type naming? I seem to recall a fairly specific prohibition on stutter-types.


Replies

kbolinoyesterday at 11:45 PM

Repeating the package name is fine if it's exactly the same name (modulo capitalization) and there's nothing better to name the type anyway. The style issue would arise with e.g. uuid.UUIDVersion, which should just be named uuid.Version. There used to be a gopls lint that would flag names like uuid.UUID but it got relaxed awhile ago.

coder543yesterday at 11:45 PM

No. What else could it reasonably be named? Hard to imagine.

The rule has always been intended to cover types that have another word in them but still choose to pointlessly repeat the package name.

`uuid.UUIDGenerator` is a hypothetical example of the anti-pattern that would instead be better named as `uuid.Generator`.

show 2 replies