Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
golang with thrift未实现thrift.TProcessorFunction(处理方法类型错误)_Go_Thrift - Fatal编程技术网

golang with thrift未实现thrift.TProcessorFunction(处理方法类型错误)

golang with thrift未实现thrift.TProcessorFunction(处理方法类型错误),go,thrift,Go,Thrift,我得到这个错误: # metric_system ./metric_system.go:227: cannot use myStructProviderProcessorGetMyStruct literal (type *myStructProviderProcessorGetMyStruct) as type thrift.TProcessorFunction in assignment: *myStructProviderProcessorGetMyStruct does not

我得到这个错误:

# 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和thrift 0.10.0构建简单的go应用程序时 复制:

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() }

感谢任何帮助

错误说明一切,您实现的
过程
方法不符合接口要求。缺少第一个参数,即
context.context

错误说明了一切,您实现的
过程
方法不符合接口要求。缺少第一个参数,即
context.context

将git分支切换到0.10.0

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

thrift.git git:(主)✗ 查看所有的分支
主人
remotes/origin/0.1.x
*遥控器/原点/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
遥控器/原点/0.9.1
遥控器/原点/0.9.2
遥控器/原点/0.9.3
remotes/origin/0.9.x
遥控器/原点/磁头->原点/主控
遥控器/源/主
远程/origin/py编译器

将git分支切换到0.10.0

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

thrift.git git:(主)✗ 查看所有的分支
主人
remotes/origin/0.1.x
*遥控器/原点/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
遥控器/原点/0.9.1
遥控器/原点/0.9.2
遥控器/原点/0.9.3
remotes/origin/0.9.x
遥控器/原点/磁头->原点/主控
遥控器/源/主
远程/origin/py编译器

我通过使用thrift to genergate go代码的主分支解决了这个问题。

我通过使用thrift to genergate go代码的主分支解决了这个问题。

原因是您的节俭版本不同,可能您使用0.9.2版本编译节俭协议,但包含节俭库文件的版本是1.0.0版本

原因是您的节俭版本不同,可能您使用0.9.2版本编译节俭协议,但包含节俭库文件的版本是1.0.0版本

和metric_system.thrift文件如下所示:struct MyStruct{1:i64 myInt,}service MyStructProvider{MyStruct getMyStruct(),}在发布有关问题的文章时,在问题中包含相关代码会很有帮助。metric_system.thrift文件如下所示:struct MyStruct{1:i64 myInt,}service MyStructProvider{MyStruct getMyStruct(),}当发布关于某个问题的帖子时,在问题中包含相关代码会很有帮助。