1月 232015
 

缘起

有些时候为了避免参数的copy,会尽可能将参数定义为指针类型;如果参数是一个接口,那么是不是要定义为接口的指针呢?如果不定一为指针是不是会导致“值传递”呢?

测试

 

http://play.golang.org/p/sw7ejPVV1t

结论

永远不要把接口参数前面添加一个星号

 Posted by at 下午 4:01

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据