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

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -