Thrift Compiler(0.9.3) 生成 Thrift 包中未定义的函数 thrift.PrependError

Thrift Compiler(0.9.3) Generates Function thrift.PrependError Which is Undefined In Thrift Package

我使用thrift编译器(0.9.3)生成gen-go文件夹,而编译器生成一个函数thrift.PrependError,在thrift包中找不到( git.apache.org/thrift.git/lib/go/thrift)。

我应该使用 thrift 编译器 (0.9.2) 吗?

在 Thrift 0.9.3 中添加了 Prepend 错误,并且存在于当前代码库中:

https://github.com/apache/thrift/blob/53dd39833a08ce33582e5ff31fa18bb4735d6731/lib/go/thrift/exception.go

https://github.com/apache/thrift/commit/527b6d9c86a7e5cde14cbb09a0e3103be0791c3a#diff-d28b48f0840fec65d4a9ece357194970R32

如果在您的本地图书馆中找不到它,您需要更新您的本地(或销售)版本的 Thrift。

请记住,您的 thrift 生成器二进制文件(在 /usr/local/bin/thrift 中)可以是与您在 $GOPATH 中的软件包不同的版本。始终确保将两者一起更新。

Should I use thrift compiler (0.9.2)?

您应该确保并仔细检查Thrift 编译器的版本与正在使用的 Thrift 库 的版本匹配。 Thrift 编译器生成的代码和库代码相互依赖,它们是同一个拼图的两块。只要您保持一致,您使用的 Thrift 版本并不重要。

除此之外,目前稳定版是0.9.3,这也是推荐的版本。