Go theorytheory 0/50 · 0%
Design · medium

32. Struct Design and API Style

Options, constructors and zero values.

Aim for useful zero values so `var b Buffer` works without setup. Where configuration is complex, use functional options rather than long parameter lists. Keep exported surfaces small, document behaviour, and avoid returning interfaces from constructors.

Check your understanding

  1. 1. Functional options replace…

  2. 2. Good Go APIs prefer…