‘Why use Go?’ might seem like an odd question to pose on a website written by someone who works as a freelance Go developer. Surely I think Go is great, and should be used everywhere? As with any language though, Go has its strong and weak points.
Cross-platform toolchain
Go has the best cross-platform toolchain for generating binaries (I don’t think comparing with interpreted languages is fair in this case). This is really useful if, like me, you develop on one platform but deploy to others. I prefer developing on Linux, because it has all the tools I need to automate parts of my workflow and make me as productive as possible. However, I often need to deploy software to Windows - unsurprisingly given its market share.
Whilst you can get other languages to compile to different platforms, in my experience it’s nowhere near as easy as Go. Take C for example - pretty much every platform of note has a C compiler, if only because the operating system is usually written in that language. Cross-compiling C can be a nightmare though - a combination of trial and error with strange linker errors that don’t describe the source of the problem. I spent a long time trying to get a GCC cross compiler working, and whilst I did make some progress, it still failed whenever it needed to link against libraries (which nearly all C code needs to do at some point).
Static binaries
By default, Go produces a single static binary for a project, with all dependencies included. This makes deployment extremely easy, as only one file needs to be copied, and there are a variety of ways to do this - even via USB stick if necessary for machines without a network connection. Single coding style
I don’t agree with everything that gofmt
requires, but having a single coding style does make it easier to read code written by other people - including a past version of myself. It’s also easy to get editors such as Visual Studio Code to auto-format each time a Go file is saved, so you don’t even have to remember all the rules.