Thrift Go Software Library
License
=======
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Using Thrift with Go
====================
Thrift supports Go 1.7+
In following Go conventions, we recommend you use the 'go' tool to install
Thrift for go.
$ go get github.com/apache/thrift/lib/go/thrift/...
Will retrieve and install the most recent version of the package.
A note about optional fields
============================
The thrift-to-Go compiler tries to represent thrift IDL structs as Go structs.
We must be able to distinguish between optional fields that are set to their
default value and optional values which are actually unset, so the generated
code represents optional fields via pointers.
This is generally intuitive and works well much of the time, but Go does not
have a syntax for creating a pointer to a constant in a single expression. That
is, given a struct like
struct SomeIDLType {
OptionalField *int32
}
, the following will not compile:
x := &SomeIDLType{
OptionalField: &(3),
}
(Nor is there any other syntax that's built in to the language)
As such, we provide some helpers that do just this under lib/go/thrift/. E.g.,
x := &SomeIDLType{
OptionalField: thrift.Int32Ptr(3),
}
And so on. The code generator also creates analogous helpers for user-defined
typedefs and enums.
Adding custom tags to generated Thrift structs
==============================================
You can add tags to the auto-generated thrift structs using the following format:
struct foo {
1: required string Bar (go.tag = "some_tag:\"some_tag_value\"")
}
which will generate:
type Foo struct {
Bar string `thrift:"bar,1,required" some_tag:"some_tag_value"`
}
没有合适的资源?快使用搜索试试~ 我知道了~
从零开始基于go-thrift创建一个RPC服务.zip
共206个文件
go:90个
php:71个
thrift:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 120 浏览量
2024-05-24
10:21:22
上传
评论
收藏 305KB ZIP 举报
温馨提示
从零开始基于go-thrift创建一个RPC服务Go语言(也称为Golang)是由Google开发的一种静态强类型、编译型的编程语言。它旨在成为一门简单、高效、安全和并发的编程语言,特别适用于构建高性能的服务器和分布式系统。以下是Go语言的一些主要特点和优势: 简洁性:Go语言的语法简单直观,易于学习和使用。它避免了复杂的语法特性,如继承、重载等,转而采用组合和接口来实现代码的复用和扩展。 高性能:Go语言具有出色的性能,可以媲美C和C++。它使用静态类型系统和编译型语言的优势,能够生成高效的机器码。 并发性:Go语言内置了对并发的支持,通过轻量级的goroutine和channel机制,可以轻松实现并发编程。这使得Go语言在构建高性能的服务器和分布式系统时具有天然的优势。 安全性:Go语言具有强大的类型系统和内存管理机制,能够减少运行时错误和内存泄漏等问题。它还支持编译时检查,可以在编译阶段就发现潜在的问题。 标准库:Go语言的标准库非常丰富,包含了大量的实用功能和工具,如网络编程、文件操作、加密解密等。这使得开发者可以更加专注于业务逻辑的实现,而无需花费太多时间在底层功能的实现上。 跨平台:Go语言支持多种操作系统和平台,包括Windows、Linux、macOS等。它使用统一的构建系统(如Go Modules),可以轻松地跨平台编译和运行代码。 开源和社区支持:Go语言是开源的,具有庞大的社区支持和丰富的资源。开发者可以通过社区获取帮助、分享经验和学习资料。 总之,Go语言是一种简单、高效、安全、并发的编程语言,特别适用于构建高性能的服务器和分布式系统。如果你正在寻找一种易于学习和使用的编程语言,并且需要处理大量的并发请求和数据,那么Go语言可能是一个不错的选择。
资源推荐
资源详情
资源评论
收起资源包目录
从零开始基于go-thrift创建一个RPC服务.zip (206个子文件)
Makefile.am 4KB
Makefile.am 4KB
Makefile.am 2KB
Makefile.am 1KB
php_thrift_protocol.cpp 35KB
.DS_Store 6KB
.gitignore 11B
simple_json_protocol.go 35KB
client_error_test.go 25KB
Service.go 24KB
simple_json_protocol_test.go 23KB
compact_protocol.go 22KB
json_protocol_test.go 21KB
serializer_types_test.go 17KB
protocol_test.go 15KB
protocol_mock.go 14KB
User.go 14KB
json_protocol.go 14KB
lowlevel_benchmarks_test.go 11KB
binary_protocol.go 11KB
debug_protocol.go 10KB
thrifttest_driver.go 9KB
optional_fields_test.go 8KB
http_client.go 7KB
simple_server.go 6KB
multiplexed_protocol_test.go 6KB
transport_test.go 6KB
thrifttest_handler.go 6KB
iostream_transport.go 5KB
greeter-remote.go 5KB
multiplexed_protocol.go 5KB
ssl_socket.go 5KB
framed_transport.go 5KB
serializer_test.go 5KB
protocol.go 5KB
required_fields_test.go 4KB
socket.go 4KB
application_exception.go 4KB
numeric.go 4KB
zlib_transport.go 4KB
simple_server_test.go 3KB
server_socket.go 3KB
protocols_test.go 3KB
ssl_server_socket.go 3KB
http_client_test.go 3KB
one_way_test.go 3KB
rich_transport_test.go 3KB
main.go 2KB
buffered_transport.go 2KB
encoding_json_test.go 2KB
exception_test.go 2KB
client.go 2KB
processor_factory.go 2KB
memory_buffer.go 2KB
transport_exception.go 2KB
pointerize.go 2KB
http_transport.go 2KB
protocol_exception.go 2KB
compact_protocol_test.go 2KB
serializer.go 2KB
transport_exception_test.go 2KB
transport.go 2KB
zlib_transport_test.go 2KB
rich_transport.go 2KB
field.go 2KB
iostream_transport_test.go 2KB
server_socket_test.go 2KB
gotag_test.go 2KB
application_exception_test.go 2KB
deserializer.go 2KB
type.go 1KB
client_test.go 1KB
exception.go 1KB
ignoreinitialisms_test.go 1KB
transport_factory.go 1KB
server_transport.go 1KB
server.go 1KB
initialisms_test.go 1KB
compile_test.go 1KB
struct_args_rets_test.go 1KB
union_binary_test.go 1KB
messagetype.go 1KB
names_test.go 1KB
binary_key_test.go 1KB
common_test.go 1KB
union_default_value_test.go 1KB
buffered_transport_test.go 980B
framed_transport_test.go 969B
binary_protocol_test.go 957B
protocol_factory.go 956B
memory_buffer_test.go 952B
context.go 881B
server_test.go 880B
context.go 877B
Service-consts.go 423B
User-consts.go 423B
GoUnusedProtection__.go 161B
php_thrift_protocol.h 1KB
Makefile.in 44KB
Makefile.in 24KB
共 206 条
- 1
- 2
- 3
资源评论
生瓜蛋子
- 粉丝: 3912
- 资源: 7441
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功