All topics
Frontend · Learning hub

Golang-advanced notes for developers

Master Golang-advanced with a curated set of 1 developer notes — core concepts, patterns, and interview prep. Maintained by the DevRecall team.

Save this stack to your DevRecallMore Frontend notes
Golang-advanced

Go Interview Questions

Go Interview Questions Goroutines vs threads? Goroutines are lightweight (2KB stack, grows as needed) vs OS threads (1MB+). Scheduled by Go runtime (M:N threadi

Go Interview Questions

  • Goroutines vs threads? Goroutines are lightweight (2KB stack, grows as needed) vs OS threads (1MB+). Scheduled by Go runtime (M:N threading), not OS. Millions can run concurrently. Communicate via channels, not shared memory

  • What is a channel? Typed conduit for goroutine communication. Unbuffered: send blocks until receive (synchronization). Buffered: send blocks only when full. Close to signal no more values — range over channel until closed

  • How to avoid goroutine leaks? Use context.WithCancel/Timeout. Select on done channel. Never start a goroutine without knowing how it will stop. Use errgroup for coordinated cancellation

  • Interfaces in Go? Satisfied implicitly — no "implements" keyword. Any type with matching methods satisfies the interface. Empty interface{} (any) accepts all types. Small interfaces preferred (io.Reader = one method)

  • Error handling philosophy? Errors are values, returned explicitly (not thrown). Check every error. Wrap with fmt.Errorf("context: %w", err). Unwrap with errors.Is() / errors.As(). Use panic only for unrecoverable states

  • Difference between make and new? new(T): allocates zero-value T, returns *T. make(T, args): for slices/maps/channels only, initializes internal structure, returns T (not pointer). Use make for those three types, new rarely

  • How does garbage collection work? Concurrent tri-color mark-and-sweep GC. Runs concurrently with program. Very low pause times (<1ms). Use sync.Pool to reduce allocations. Profile with pprof to find alloc hotspots

  • When to use mutex vs channel? Mutex: protecting shared state (counter, cache). Channel: passing data between goroutines, signaling. Rule: "Share memory by communicating" — channels. But mutexes are fine for simple state protection

Keep your Golang-advanced knowledge sharp.

Save this stack to your personal DevRecall — add your own notes, track what you're learning, and share what you know with the community.

Get started — free forever