Go Time: Golang, Software Engineering

The bits of Go we avoid (and why)

15 snips
Mar 16, 2023
Ask episode
AI Snips
Chapters
Transcript
Episode notes
ADVICE

Avoid "new"

  • Avoid using the new keyword in Go.
  • Use struct literals for instantiation, as it's consistent and readable, even without setting fields.
INSIGHT

Generic Zero Values with "new"

  • new(T) is mainly useful in generic Go code.
  • It helps return the zero value of a generic type T when a direct zero value expression isn't available.
ADVICE

Avoid Full Slice Expressions

  • Avoid full slice expressions (with a third index for capacity).
  • Their behavior isn't intuitive and may confuse readers; use slices.clip for clarity.
Get the Snipd Podcast app to discover more snips from this episode
Get the app