learning golang

learning golang , I want to share with you how I taught myself to program in Go.  Teaching yourself to program in a new language such as Go is not difficult if you have some experience in C like languages.  Choosing to learn Go is a personal choice for some people, and for others it may be part of their job.   Some of my main reasons for deciding to learn golang are:

  • Go is very fast, almost as fast as C, but you get memory management built into the runtime.
  • Go has arrays and maps ( dictionaries ) built into the language so you can focus on building better algorithms.
  • Go comes with a great standard library with high level building blocks such as a web server.  This allows you to focus on building solutions rather than reinventing the wheel.
  • Go is opinionated, so you can get to work using choices the language creators made rather than spinning your wheels thinking about other things.
  • Go promises backwards compatibility in version 1.x so upgrading your version of go will not break your code, this is a game changer for use in enterprise.
  • Go has a great community

The first thing I did to teach myself to program in Go was to take the Tour of Go

The tour is a great interactive tutorial that helps you get your feet wet with the language.  It works right inside your web browser, so you do not have to install anything to get going right away with learning go.

Next, I read Effective Go   This really helped me learn how to write idiomatic go. It is written in the same style as the Zen of Python.

Here is a little trick for kindle owners.  I was on a long flight back from Asia, and I wanted to read Effective Go, but was not going to have internet on the flight I was on.  I had my kindle white with me, and I sent the link to Effective Go to my special kindle email that Amazon provides.   The service reformats websites and creates a ebook that you can load onto your kindle.  If you do not have a Kindle, all is not lost, there is a Kindle app for the phone, so this trick will still work.

I also searched for some good books on the kindle, but I did not find any that I liked at that time.  Later on, the Go Programming Language by Alan Donovan and Brian Kernighan  came out.  I had already learned Go by them but I still bought it as it is still a great read with great examples that show you how to write idiomatic Go.  I would recommend getting a copy if your just starting out or have not programmed any big projects in Go.  The book teaches you Go in an incremental fashion using simple exercises that build upon each other.  It is one of the best ways to learn Go right now.

Once you have read a little information on how to program in Go, its best to just dive in and start programming something.   I found Go by Example to be very helpful as it shows simple examples of how to use arrays, maps, slices, and other constructs in the language.

I found the list of awesome Go libraries to be very useful just to see what people have already written.

My greatest resource so far has been reading the source code of the Go standard library.   I have heard many other people say this, and I could not agree more with this.

The Go community is really great and really helpful to people just starting out in Go.  The Google group Golang-nuts  Has a large number of experts in Go that can answer questions and make suggestions.   I also check the subreddit /r/golang  for people announcing new projects.   I have found some real gems on there.

I wrote up a very useful post on how to find Go projects  if you want to search for a golang project by keyword.  This is helpful if you trying to see if someone has already created a library for something you need.

The final step I took in teaching myself Go was just to choose a project and start coding in it.  Programming is an art just as much as it is a science.  If you want to get better at programming, you have to practice programming.