We discuss how in Go to safely “extract” a concrete type from an interface via
type assertion
v
,
ok
:=
x
.(
T
): when you need to check
ok, why the form without
ok is dangerous (panic), how to check behavior through interfaces (
fmt.Stringer, “temporary” errors), and what pitfalls are associated with
T vs
*T and
nil. In the end — typical mistakes and readability criteria.