You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
case Struct:
// If the type is comparable, then compare directly with zero.ifv.typ().Equal!=nil&&v.typ().Size() <=maxZero {
ifv.flag&flagIndir==0 {
returnv.ptr==nil
}
// See noescape justification above.returnv.typ().Equal(noescape(v.ptr), unsafe.Pointer(&zeroVal[0]))
}
n:=v.NumField()
fori:=0; i<n; i++ {
if!v.Field(i).IsZero() {
returnfalse
}
}
returntrue
1.2 TODO 要了解的点
看下编译的时候如何填充.Equal和Size字段的。
The text was updated successfully, but these errors were encountered:
记录reflect相关的碎片化知识点,以及自问自答
1. IsZero接口
1.1 IsZero接口
如果struct是编译时的值是空的,IsZero是知道的。
下面的内容摘自IsZero的实现,编译器版本是go1.21.0
1.2 TODO 要了解的点
看下编译的时候如何填充.Equal和Size字段的。
The text was updated successfully, but these errors were encountered: