I was looking at ways to do method chaining in Go and found this article from Jon Calhoun about functional options. He made some really good points. I read through it probably three times, and being the dull knife that I am had trouble wrapping my head around it. So I sat down and tried to figure it out. I figured I’d put this post together for anyone who is in the same boat as me and wants a nice simple example of how functional options work.
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. inputs stdin file 1