手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2013年05月31日的文章

type ttt struct{} var t ttt; 与 t := New(ttt) 有什么区别?

 在实际中遇到了标题的问题,即:

type ttt struct{}
var t ttt;
t := New(ttt)
有什么区别?
 
包括手册上都说好象没啥区别( 我记得好象是《go 云动力》)
但是我在测试jsonrpc的时候,用 var t ttt的方式 时:
XML/HTML代码
  1. 2013/05/31 12:46:35 rpc.Register: type Arith has no exported methods of suitable type (hint: pass a pointer to value of that type)  
换成t:=New(ttt),就OK了
------
新手,暂时不知其所以然,先记录和备份一下