win7环境下,golang thrift demo代码编译不经过

用官方的教程代码:http://thrift.apache.org/tutorial/gogit

用网友提供的代码:Golang RPC 之 Thriftapache

都出现以下状况编辑器

情况1:spa

编辑器中就会提醒 Cannot use 'processor' (type *FormatDataProcessor) as type TProcessor orm

情况2:server

# ThriftDemo/example
example\example.go:232: cannot use formatDataProcessorDoFormat literal (type *formatDataProcessorDoFormat) as type thrift.TProcessorFunction in assignment:
*formatDataProcessorDoFormat does not implement thrift.TProcessorFunction (wrong type for Process method)
have Process(int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
want Process(context.Context, int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
example\example.go:240: not enough arguments in call to processor.Process
have (int32, thrift.TProtocol, thrift.TProtocol)
want (context.Context, int32, thrift.TProtocol, thrift.TProtocol)教程

 

分析缘由:get

一开始我觉得是和环境有关系,我今天在公司用的是win7 64 + Go 1.9.1(发现官方server代码编译不过,从1.8.0升级上来的) + thrift 0.10.0官方demo和网上demo怎么都编译不过server端,client端没有问题, 刚在家里Mac上 Go 1.8.0 + thrift 0.10.0一样的代码,没有问题,可是我忽略的另一个问题,thrift lib中的go文件 ,公司的是删了今天从新下的,家里的是好几个月以前it

 

推测缘由: io

thrift是好几个月前安装的,而我最近go get  git.apache.org/thrift.git/lib/go/thrift 更新了代码,形成的代码版本不一致

 

解决方案:

最终得出结论,是thrift版本和git.apache.org/thrift.git/lib/go/thrift的版本不一致形成的,今天在win7平台上也跑过了,我直接在GOPATH环境下先删除 git.apache.org/thrift.git/目录,而后mkdir -p git.apache.org/thrift.git/lib/go/thrift最后,将thrift安装目录下的代码拷贝过去,能经过个人thrift的目录:D:\thrift\src\thrift\lib\go\thrift

相关文章
相关标签/搜索