Extract function to DRY code
Follow golang style
Extract function

Small functions are goodness.
Fix issues suggested by `go vet`
Close potential resource leak
Minor style tweak
Only consider published things to be failing