Go defer实现
// _defer结构体持有指向下一个要被执行的 defer 结构体的指针
type _defer struct {
siz int32 // 包含参数和结果
started bool
heap bool
// openDefer indicates that this _defer is for a frame with open-coded
// defers. We have only one defer record for the entire frame (which may
// currently have 0, 1, or more defers active).
openDefer bool
sp uintptr // 延迟调用时的sp
pc uintptr // 延迟调用时的pc
fn *funcval // 下一个要被执行的延迟函数
_panic *_panic // 执行延迟调用时的panic信息
link *_defer
// If openDefer is true, the fields below record values about the stack
// frame and associated function that has the open-coded defer(s). sp
// above will be the sp for the frame, and pc will be address of the
// deferreturn call in the function.
fd unsafe.Pointer // funcdata for the function associated with the frame
varp uintptr // value of varp for the stack frame
// framepc is the current pc associated with the stack frame. Together,
// with sp above (which is the sp associated with the stack frame),
// framepc/sp can be used as pc/sp pair to continue a stack trace via
// gentraceback().
framepc uintptr
}