title: InvalidOffsetof layout: article

InvalidOffsetof occurs when unsafe.Offsetof is called with a method
selector, rather than a field selector, or when the field is embedded via
a pointer.

Per the spec:

 "If f is an embedded field, it must be reachable without pointer
 indirections through fields of the struct. "

Example:
 import "unsafe"

 type T struct { f int }
 type S struct { *T }
 var s S
 var _ = unsafe.Offsetof(s.f)

Example:
 import "unsafe"

 type S struct{}

 func (S) m() {}

 var s S
 var _ = unsafe.Offsetof(s.m)