用官方的教程代码: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

最新文章

  1. canvas钟表
  2. 【GO】GO语言学习笔记一
  3. JavaScript---DOM文档
  4. github中non-fast-forward错误的解决
  5. Android开源项目SlidingMenu深切解析
  6. Graphviz使用简介(中文乱码的问题)
  7. js获取每个按键的ASCII值
  8. 在共享DLL中使用MFC 和在静态库中使用MFC的区别
  9. BinarySearchTree-二叉搜索树
  10. zabbix杂文二
  11. Thinkphp 3.2中文章详情页的上一篇 下一篇文章功能
  12. Django_MTV视图
  13. 2018-2019-2 20165337《网络对抗技术》Exp2 后门原理与实践
  14. [Swift]LeetCode969.煎饼排序 | Pancake Sorting
  15. 三:OVS+GRE之完整网络流程
  16. Laravel 5.2+ 使用url()全局函数返回前一个页面的地址
  17. win10 python3.5 自动补全设置
  18. oracle java连接配置
  19. JAVA框架 json数据交互
  20. Find substring with K distinct characters

热门文章

  1. 内网 LAN IPv6 环境配置 H3C S5500 Huawei S5700
  2. Ansible 小手册系列 二十(经常遇到的问题)
  3. JS正则表达式的分组匹配
  4. python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'
  5. SQL2008R2 收缩数据库问题 - 日志文件不变小
  6. Docker的安装及操作
  7. C++面向对象高级编程(五)类与类之间的关系
  8. 剑指offer--50.滑动窗口的最大值
  9. L158
  10. Flexible 弹性盒子模型之CSS order 属性