/ / golang with thrift implementiert keine thrift.TProcessorFunction (falscher Typ für Process-Methode) - go, thrift

Golang mit Sparsamkeit implementiert nicht thrift.TProcessorFunction (falscher Typ für Process-Methode) - gehen, Sparsamkeit

Ich erhalte diesen Fehler:

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

Wenn ich einfache Go-App mit Golang 1.8.3 und Sparsamkeit 0.10.0 zu bauen bin Reproduzieren:

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

Ordnerstruktur

./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

Datei metric_system.thrift:

struct MyStruct {
1: i64 myInt,
}

service MyStructProvider { MyStruct getMyStruct() }

Jede Hilfe wird geschätzt

Antworten:

0 für die Antwort № 1

Der Fehler sagt alles, die Process Methode, die Sie implementiert haben, erfüllt nicht die Schnittstellenanforderung. Sie vermissen das erste Argument, a context.Context.


0 für die Antwort № 2

Schalten Sie Ihren Git-Zweig auf 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 für die Antwort № 3

Ich liebte dieses Problem, indem ich den Master-Zweig der Sparsamkeit nutzte, um Code zu erergen. https://github.com/apache/thrift/tree/master


0 für die Antwort № 4

Der Grund ist, dass Ihre Sparversion anders ist, vielleicht kompilieren Sie das Sparsamkeitsprotokoll mit Version 0.9.2, aber schließen Sie die Sparsamkeitsbibliotheksdatei ist Version 1.0.0 ein