News for hackers. Stuff that matters.
Re:Goodbye Python, Hello Go by arendtio on Friday August 03, 2018 @09:30AM (#17679640)
Thanks for giving an equivalent example in Go :-)

I think for this small size of an example program the error checking in Go is pure overhead, but as soon as the program starts to have a few more functions it will be very useful to have more options than just to abort on fail (Bash trap style / set -e). So I don't have any problem with 'polluting' my source with `if err != nil` checks ;-)

What I am more concerned about are the different ways I have to call functions from different libraries like

  resp, err := http.Get(url)
  ...
  defer resp.Body.Close()
  body, err := ioutil.ReadAll(resp.Body)
That is a lot more 'special' than the other function calls and the bash version and probably requires more documentation reading than '$ curl --help'. But hey, thanks to your example I have a starting point and probably are going to experiment with it in the new future.

For all the others who wrote that Bash is the right tool for the job: I read your warnings, opinions and suggestions and will keep them in mind while exploring the possibilities of using Go for script like jobs.

There are no comments on this comment yet.