go - How to force compiler to control value/pointer-to-value func arguments? -
dealing go's funcs discovered 1 can't force compiler control whether pass value or pointer-to-value argument when using 'generic' interface{} type.
func f(o interface{}) { ... }
the obvious solution use following modification:
func f(o *interface{}) { ... }
although compiled didn't find step right. so, there means state want pass pointer?
no. @ compile time, interface{}
, empty interface, type.
all types implement empty interface:
interface{}
interface types
Comments
Post a Comment