Skip to content
On this page

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. Go Internals is nice for more in depth look.

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.

That said, I am exploring writing more code in Rust specifically because of Tauri.

It's useful to setup linters like GolangCI-Lint or commands from Go Recipes.

Guide to Go profiling, tracing and observability is useful read.

Concurrency in Go Fundamentals & Go Concurrency Patterns are great to read to understand concurrency better. Concurrency is not Parallelism.

ko seems nice for deploying Go as containers.

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

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

// Check for boolean flag (--dev here)
boolArgPtr := flag.Bool("dev", false, "Explain command..")
flag.Parse()
if *boolArgPtr != false {
  // ..
}