2017-08-04 22 views
-1

我收到此錯誤:golang與節儉沒有實現thrift.TProcessorFunction(類型錯誤加工方法)

# metric_system 
./metric_system.go:227: cannot use myStructProviderProcessorGetMyStruct literal (type *myStructProviderProcessorGetMyStruct) as type thrift.TProcessorFunction in assignment: 
    *myStructProviderProcessorGetMyStruct 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) 
./metric_system.go:235: not enough arguments in call to processor.Process 
    have (int32, thrift.TProtocol, thrift.TProtocol) 
    want (context.Context, int32, thrift.TProtocol, thrift.TProtocol) 

當我使用golang 1.8.3和節儉0.10.0 構建簡單的去應用要重現:

2038 thrift -r --gen go metric_system.thrift 
2040 cp -r gen-go/* src 
2041 cd src 
2042 go build 

文件夾結構

./metric_system.thrift 
./.settings 
./.settings/language.settings.xml 
./src 
./src/metric_system 
./src/metric_system/my_struct_provider-remote 
./src/metric_system/my_struct_provider-remote/my_struct_provider-remote.go 
./src/metric_system/metric_system.go 
./src/metric_system/GoUnusedProtection__.go 
./src/metric_system/metric_system-consts.go 
./src/main.go 
./.cproject 
./pkg 
./pkg/linux_amd64 
./.project 
./bin 
./gen-go 
./gen-go/metric_system 
./gen-go/metric_system/my_struct_provider-remote 
./gen-go/metric_system/my_struct_provider-remote/my_struct_provider-remote.go 
./gen-go/metric_system/metric_system.go 
./gen-go/metric_system/GoUnusedProtection__.go 
./gen-go/metric_system/metric_system-consts.go 

metric_system.thrift文件:

struct MyStruct { 
    1: i64 myInt, 
} 

service MyStructProvider { MyStruct getMyStruct() } 

任何幫助表示讚賞

+0

和metric_system.thrift文件是這樣的:結構MYSTRUCT { \t 1:I64敏, } 服務MyStructProvider { \t MYSTRUCT getMyStruct(), } – user2982256

+0

當張貼有關的問題,這是有幫助的,包括在你的問題相關的代碼。 – Adrian

回答

0

錯誤說,這一切,你已經實現了不符合接口要求的Process方法。你錯過了第一個參數,一個context.Context

0

用節儉的主分支genergate去你的代碼分支的git切換到0.10.0

$GOPATH:git.apache.org/thrift.git/lib/go/thrift

thrift.git git:(master) ✗ git branch -a master remotes/origin/0.1.x * remotes/origin/0.10.0 remotes/origin/0.2.x remotes/origin/0.3.x remotes/origin/0.4.x remotes/origin/0.5.x remotes/origin/0.6.x remotes/origin/0.7.x remotes/origin/0.8.x remotes/origin/0.9.1 remotes/origin/0.9.2 remotes/origin/0.9.3 remotes/origin/0.9.x remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/py-compiler

0

的原因是你的節儉的版本是不同的,也許你編譯使用0.9.2版本的節儉協議,但包括節儉庫文件1.0.0版本

相關問題