NISHIO Hirokazu[Translate]
Goのインターフェイスはポインタにメソッドテーブルがついたもの
インターフェイスという言葉でJavaのインターフェイスをイメージすると混乱する。

go
// emptyInterface is the header for an interface{} value. type emptyInterface struct { typ *rtype word unsafe.Pointer } // nonEmptyInterface is the header for an interface value with methods. type nonEmptyInterface struct { // see ../runtime/iface.go:/Itab itab *struct { ityp *rtype // static interface type typ *rtype // dynamic concrete type hash uint32 // copy of typ.hash _ [4]byte fun [100000]unsafe.Pointer // method table } word unsafe.Pointer }

C言語に縛って検索してて中々見つからないなと思ったのだが、*.goの中にあったのか。


"Engineer's way of creating knowledge" the English version of my book is now available on [Engineer's way of creating knowledge]

(C)NISHIO Hirokazu / Converted from [Scrapbox] at [Edit]