In my journey to better my development skills I’ve been trying to write some small Go applications. I needed a sorter like uniq
but on a Windows machine for a project I was doing. So I decided to write one.
Unlike uniq the input does not need sorted beforehand. The program takes either stdin or can read from a file which is passed as the first argument.
stdin:
echo "test thing test thing other" | goniq
file: goniq words.txt
Iterating over 466,544 words, it took 2.1 seconds, vs uniq which took 3.378. Not sure if these statistics really mean anything, but it’s nice to see it’s on par with the default OS tools.
The source is here.
Update: This is now a Go package. Instead of just being a cli tool, you can import it into your project and directly use it. Documentation and an example is here