Skip to content

Instantly share code, notes, and snippets.

@flowchartsman
Last active July 19, 2022 13:51
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save flowchartsman/be141593ce1087e38c6787b4127d060d to your computer and use it in GitHub Desktop.
Save flowchartsman/be141593ce1087e38c6787b4127d060d to your computer and use it in GitHub Desktop.
Zero To Go

Intro

This is an experiment in self-teaching Go, starting from complete unfamiliarity with the language. The goal is to provide a step-by-step educational resource that you can follow at your own pace, where each phase effectively builds on that which came before it with as little unnecessary overlap as possible. It's very much a "living document" or work in progress, and will likely be under constant revision as I revisit advice, update sources, tweak ordering and learn more about how these resources interact to create a well-rounded knowledge of the language. Please feel free to issue feedback and make any suggestions you feel are pertinent.

Reading

  1. Go through the tour at https://tour.golang.org/list
  2. Promptly abandon all of those plans you have to use channels everywhere
  3. Read the language spec once over: https://golang.org/ref/spec
  4. https://dave.cheney.net/2017/04/26/understand-go-pointers-in-less-than-800-words-or-your-money-back
  5. Read Effective Go: https://golang.org/doc/effective_go.html
  6. Read CodeReviewComments (essentially a semi-official style guide) https://github.com/golang/go/wiki/CodeReviewComments
  7. http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/
  8. https://coder.today/tech/2018-11-10_profiling-your-golang-app-in-3-steps/ This is a very effective tool in your toolbelt, and you will use it A LOT.
  9. Some other good articles:

Software

  • IDES
    • I generally use vim & vim-go
    • vscode is excellent as well. It is only a few (but serious) problems in the vim bindings that keep me with Vim...for now.
    • goland is also very good. The JetBrains folks are very talented. It does a lot of really impressive things that the others don't, esp with regard to refactoring.
  • Other
    • Dash for OSX is great for local doc searching

Testing

Testing is a first-level concept in Go, and is very important. I recommend reading up on table driven tests, and subtests/benchmarks. These combine well.

Stick to the stdlib testing package for your first couple projects. You can branch out to test frameworks later, but I would encourage you to identify a deep need before doing so. I have yet to find a truly compelling case for other testing frameworks. Perhaps matching libraries. Maybe.

When testing services, you will find yourself having a much easier time if you use dependency injection through interfaces, and for this, nothing beats a good mocking framework. I typically use gomock, but there are others.

Advice

It helps to learn the standard library well, especially strings os and regexp.

You will eventually find yourself writing your own sort of scripty helper libraries like https://github.com/bitfield/script for quick one offs.

If you want to stay current, I recommend installing Go from source, and I've written a guide to do that here. Please let me know if you find any problems.

https://tinyurl.com/zero-to-go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment