Improve go script

Now it has better error checking.