proposal: crypto: crypto.Hash implement fmt.Stringer and export crypto.maxHash #33430
What version of Go are you using (
changed the title
crypto: crypto.Hash implement fmt.Stringer and export crypto.maxHash
Aug 3, 2019
The Stringer would be useful for all kinds of logging purposes and I personally see no drawback.
The maxHash would be useful every time you need to show something non-go the options there are for hashing. So for example every time a user can choose a hashing algorithm in a CLI or GUI or maybe you list available hashing options to a program written in another language. And your duplicating code every time when you use the alternative: importing the package and putting it into a map. So if for example one of the choices becomes insecure you need to remove the import and the map entry and if you forget one of them you've got either an unused import which cannot be detected by the compiler or you've got a panic.
So I think there are no reasons against Stringer and very few drawbacks of a renamed maxHash.