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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -