分享
  1. 首页
  2. 文章

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

liugx · · 1714 次点击 · · 开始浏览
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

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

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

都出现如下情况

状况1:

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

状况2:

# 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)

分析原因:

一开始我以为是和环境有关系,我今天在公司用的是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文件 ,公司的是删了今天重新下的,家里的是好几个月之前

推测原因:

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


有疑问加站长微信联系(非本文作者)

本文来自:博客园

感谢作者:liugx

查看原文:win7环境下,golang thrift demo代码编译不通过

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

关注微信
1714 次点击
暂无回复
添加一条新回复 (您需要 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传

用户登录

没有账号?注册
(追記) (追記ここまで)

今日阅读排行

    加载中
(追記) (追記ここまで)

一周阅读排行

    加载中

关注我

  • 扫码关注领全套学习资料 关注微信公众号
  • 加入 QQ 群:
    • 192706294(已满)
    • 731990104(已满)
    • 798786647(已满)
    • 729884609(已满)
    • 977810755(已满)
    • 815126783(已满)
    • 812540095(已满)
    • 1006366459(已满)
    • 692541889

  • 关注微信公众号
  • 加入微信群:liuxiaoyan-s,备注入群
  • 也欢迎加入知识星球 Go粉丝们(免费)

给该专栏投稿 写篇新文章

每篇文章有总共有 5 次投稿机会

收入到我管理的专栏 新建专栏