marchiosim
marchiosim

Reputation: 119

Interface implementation in Go runtime

I'm reading a book about Go. In the interfaces chapter i found this statement:

In the Go runtime, interface are implemented as a pair of pointers, one to the underlying type and one to the underlying value.

Can someone explain me these words with a concrete example?

Upvotes: 1

Views: 1411

Answers (1)

rocka2q
rocka2q

Reputation: 2784

This has pictures! Russ is the author of the initial Go gc compiler interface implementation. There have been a few minor revisions.

Go Data Structures: Interfaces
Russ Cox

This post is my take on the implementation of interface values in the “gc” compilers. This post has pictures.


For Go source code see go/src/runtime/iface.go.

Upvotes: 4

Related Questions