Replacing a one line bash script with 74 lines of Go golang