简体   繁体   中英

golang exception to rule “interface pointer can't implement interface”

In golang.org's official FAQ, under pointers there is this quote: "The insight is that although a pointer to a concrete type can satisfy an interface, with one exception a pointer to an interface can never satisfy an interface"

Out of curiosity, what is that exception to the above rule? ie when can an interface pointer implement an interface?

Just below it says:

The one exception is that any value, even a pointer to an interface, can be assigned to a variable of empty interface type (interface{}). Even so, it's almost certainly a mistake if the value is a pointer to an interface; the result can be confusing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM