Skip to main content

Go

Prefer using Go for all code I want to run not in the browser (scripts, web services, servers of all kinds) due to it's fast compile speeds & performance.

I love the tooling around it like VS Code and its Go plugin. The powerful go command line tool and the rich ecosystem of libraries and tools that people have built.

Go promotes composition over inheritance.

Tour of Go & Learn Go with Tests are great places to learn Go.

GoReleaser is useful for publishing. revive & Staticcheck are great linters.

Only thing I dislike about Go is it's verbosity especially with respect to errors. But that decision was made so all programmers are forced to not only consider the happy paths of their code & write proper error logging.

Commenting Go code

  • Comments documenting declarations should be full sentences.
  • Comments should begin with the name of the thing being described and end in a period.

Error checking

  • You can log.Fatal(err) when playing with code.
    • In actual applications you need to decide what you need to do with each error response - bail immediately, pass it to the caller, show it to the user, log it and continue, etc ...

Notes

Code

// Log error
if err != nil {
log.Fatal(err)
}