Removing the duplicate entries from a slice is cumbersome.
In Ruby, you can call .uniq
, in Go, you need a ten-line function in your source code.
Ruby: `xs.uniq`
— Gary Bernhardt (@garybernhardt) September 8, 2017
Golang: [a ten-line function written directly in your project's source code]
Similar to the issues that led to math.Round, you can Google for "golang duplicate slice" and read many different explanations of how to implement the function. It might be helpful to have just one in the standard library.
Seriously: google "golang deduplicate slice". Read a hundred responses, each showing a different ten-line function. Again, Ruby: `xs.uniq`.
— Gary Bernhardt (@garybernhardt) September 8, 2017
Some previous discussion can be found here: golang/go#12763
Here's Ruby's uniq: https://ruby-doc.org/core-2.2.0/Array.html#method-i-uniq
The Ruby implementation is > 10 lines :-)