4 ms·
A lot of the time in Go you do have to copy-paste-tweak - sorting lists for example requires quite a bit of boiler plate. That doesn't mean the code above is g
by robbrit 7y ago
A lot of the time in Go you do have to copy-paste-tweak - sorting lists for example requires quite a bit of boiler plate.
That doesn't mean the code above is good, just that the lack of generics sometimes makes copy-pasting in Go inevitable.
- jstimpfle 7y agoCan't you just do something like qsort()?
- robbrit 7y agoTechnically yes, however it is not type-safe. Idiomatic Go usually tries to be at least somewhat type-safe, and so the standard library's sort package uses interfaces instead of comparison functions. This is a bit more tedious to write unfortunately.