We explore why an interface in Go is not a “box”, but a pair of (dynamic type, dynamic value), and where the trap
typed nil comes from: when
err looks like
nil when printed, but the comparison
err
!=
nil is unexpectedly true. Using practical examples with
error,
fmt.Stringer, and diagnostics via
fmt.Printf(
"%T"), we reinforce the rule: in the success branch, return exactly
nil, not
(*T)(nil) wrapped in an interface.