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

相關文章
相關標籤/搜索