当前位置: 首页 > news >正文

potobuf生成文件

package example;

enum FOO { X = 17; };

message Test {
required string label = 1;
optional int32 type = 2 [default=77];
repeated int64 reps = 3;
optional group OptionalGroup = 4 {
required string RequiredField = 5;
}
}

protobuf中test.proto生成test.pd.go

  // Code generated by protoc-gen-go. DO NOT EDIT.
    // source: test.proto
    
    package example
    
    import (
    	fmt "fmt"
    	proto "github.com/golang/protobuf/proto"
    	math "math"
    )
    
    // Reference imports to suppress errors if they are not otherwise used.
    var _ = proto.Marshal
    var _ = fmt.Errorf
    var _ = math.Inf
    
    // This is a compile-time assertion to ensure that this generated file
    // is compatible with the proto package it is being compiled against.
    // A compilation error at this line likely means your copy of the
    // proto package needs to be updated.
    const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
    
    type FOO int32
    
    const (
    	FOO_X FOO = 17
    )
    
    var FOO_name = map[int32]string{
    	17: "X",
    }
    
    var FOO_value = map[string]int32{
    	"X": 17,
    }
    
    func (x FOO) Enum() *FOO {
    	p := new(FOO)
    	*p = x
    	return p
    }
    
    func (x FOO) String() string {
    	return proto.EnumName(FOO_name, int32(x))
    }
    
    func (x *FOO) UnmarshalJSON(data []byte) error {
    	value, err := proto.UnmarshalJSONEnum(FOO_value, data, "FOO")
    	if err != nil {
    		return err
    	}
    	*x = FOO(value)
    	return nil
    }
    
    func (FOO) EnumDescriptor() ([]byte, []int) {
    	return fileDescriptor_c161fcfdc0c3ff1e, []int{0}
    }
    
    type Test struct {
    	Label                *string             `protobuf:"bytes,1,req,name=label" json:"label,omitempty"`
    	Type                 *int32              `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"`
    	Reps                 []int64             `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"`
    	Optionalgroup        *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup,json=optionalgroup" json:"optionalgroup,omitempty"`
    	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
    	XXX_unrecognized     []byte              `json:"-"`
    	XXX_sizecache        int32               `json:"-"`
    }
    
    func (m *Test) Reset()         { *m = Test{} }
    func (m *Test) String() string { return proto.CompactTextString(m) }
    func (*Test) ProtoMessage()    {}
    func (*Test) Descriptor() ([]byte, []int) {
    	return fileDescriptor_c161fcfdc0c3ff1e, []int{0}
    }
    
    func (m *Test) XXX_Unmarshal(b []byte) error {
    	return xxx_messageInfo_Test.Unmarshal(m, b)
    }
    func (m *Test) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    	return xxx_messageInfo_Test.Marshal(b, m, deterministic)
    }
    func (m *Test) XXX_Merge(src proto.Message) {
    	xxx_messageInfo_Test.Merge(m, src)
    }
    func (m *Test) XXX_Size() int {
    	return xxx_messageInfo_Test.Size(m)
    }
    func (m *Test) XXX_DiscardUnknown() {
    	xxx_messageInfo_Test.DiscardUnknown(m)
    }
    
    var xxx_messageInfo_Test proto.InternalMessageInfo
    
    const Default_Test_Type int32 = 77
    
    func (m *Test) GetLabel() string {
    	if m != nil && m.Label != nil {
    		return *m.Label
    	}
    	return ""
    }
    
    func (m *Test) GetType() int32 {
    	if m != nil && m.Type != nil {
    		return *m.Type
    	}
    	return Default_Test_Type
    }
    
    func (m *Test) GetReps() []int64 {
    	if m != nil {
    		return m.Reps
    	}
    	return nil
    }
    
    func (m *Test) GetOptionalgroup() *Test_OptionalGroup {
    	if m != nil {
    		return m.Optionalgroup
    	}
    	return nil
    }
    
    type Test_OptionalGroup struct {
    	RequiredField        *string  `protobuf:"bytes,5,req,name=RequiredField" json:"RequiredField,omitempty"`
    	XXX_NoUnkeyedLiteral struct{} `json:"-"`
    	XXX_unrecognized     []byte   `json:"-"`
    	XXX_sizecache        int32    `json:"-"`
    }
    
    func (m *Test_OptionalGroup) Reset()         { *m = Test_OptionalGroup{} }
    func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) }
    func (*Test_OptionalGroup) ProtoMessage()    {}
    func (*Test_OptionalGroup) Descriptor() ([]byte, []int) {
    	return fileDescriptor_c161fcfdc0c3ff1e, []int{0, 0}
    }
    
    func (m *Test_OptionalGroup) XXX_Unmarshal(b []byte) error {
    	return xxx_messageInfo_Test_OptionalGroup.Unmarshal(m, b)
    }
    func (m *Test_OptionalGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    	return xxx_messageInfo_Test_OptionalGroup.Marshal(b, m, deterministic)
    }
    func (m *Test_OptionalGroup) XXX_Merge(src proto.Message) {
    	xxx_messageInfo_Test_OptionalGroup.Merge(m, src)
    }
    func (m *Test_OptionalGroup) XXX_Size() int {
    	return xxx_messageInfo_Test_OptionalGroup.Size(m)
    }
    func (m *Test_OptionalGroup) XXX_DiscardUnknown() {
    	xxx_messageInfo_Test_OptionalGroup.DiscardUnknown(m)
    }
    
    var xxx_messageInfo_Test_OptionalGroup proto.InternalMessageInfo
    
    func (m *Test_OptionalGroup) GetRequiredField() string {
    	if m != nil && m.RequiredField != nil {
    		return *m.RequiredField
    	}
    	return ""
    }
    
    func init() {
    	proto.RegisterEnum("example.FOO", FOO_name, FOO_value)
    	proto.RegisterType((*Test)(nil), "example.Test")
    	proto.RegisterType((*Test_OptionalGroup)(nil), "example.Test.OptionalGroup")
    }
    
    func init() { proto.RegisterFile("test.proto", fileDescriptor_c161fcfdc0c3ff1e) }
    
    var fileDescriptor_c161fcfdc0c3ff1e = []byte{
    	// 194 bytes of a gzipped FileDescriptorProto
    	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0x49, 0x2d, 0x2e,
    	0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4f, 0xad, 0x48, 0xcc, 0x2d, 0xc8, 0x49, 0x55,
    	0x3a, 0xc4, 0xc8, 0xc5, 0x12, 0x92, 0x5a, 0x5c, 0x22, 0x24, 0xc2, 0xc5, 0x9a, 0x93, 0x98, 0x94,
    	0x9a, 0x23, 0xc1, 0xa8, 0xc0, 0xa4, 0xc1, 0x19, 0x04, 0xe1, 0x08, 0x89, 0x71, 0xb1, 0x94, 0x54,
    	0x16, 0xa4, 0x4a, 0x30, 0x29, 0x30, 0x6a, 0xb0, 0x5a, 0x31, 0x99, 0x9b, 0x07, 0x81, 0xf9, 0x42,
    	0x42, 0x5c, 0x2c, 0x45, 0xa9, 0x05, 0xc5, 0x12, 0xcc, 0x0a, 0xcc, 0x1a, 0xcc, 0x41, 0x60, 0xb6,
    	0x90, 0x23, 0x17, 0x6f, 0x7e, 0x41, 0x49, 0x66, 0x7e, 0x5e, 0x62, 0x4e, 0x7a, 0x51, 0x7e, 0x69,
    	0x81, 0x04, 0x8b, 0x02, 0xa3, 0x06, 0x97, 0x91, 0xb4, 0x1e, 0xd4, 0x2e, 0x3d, 0x90, 0x3d, 0x7a,
    	0xfe, 0x50, 0x25, 0xee, 0x20, 0x25, 0x41, 0xa8, 0x3a, 0xa4, 0x4c, 0xb9, 0x78, 0x51, 0xe4, 0x85,
    	0x54, 0xb8, 0x78, 0x83, 0x52, 0x0b, 0x4b, 0x33, 0x8b, 0x52, 0x53, 0xdc, 0x32, 0x53, 0x73, 0x52,
    	0x24, 0x58, 0xc1, 0xae, 0x43, 0x15, 0xd4, 0xe2, 0xe1, 0x62, 0x76, 0xf3, 0xf7, 0x17, 0x62, 0xe5,
    	0x62, 0x8c, 0x10, 0x10, 0x04, 0x04, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x86, 0x42, 0x63, 0xe8, 0x00,
    	0x00, 0x00,
    }

相关文章:

  • GO get下载困难问题
  • c语言二叉树
  • 丹华资本与区块链
  • hyperledger生成证书命令
  • crypto-config.yaml
  • 纯净版crypto-config.yaml文件
  • hyperledger生成peer和order
  • golang实现web服务器
  • ActiveMQ消息队列
  • export对环境变量进行设置
  • hyperledger中基本网络搭建示例
  • hyperledger中docker-compose文件示例
  • hyperledger多节点交易
  • 微服务架构
  • 微服务架构的特性
  • 77. Combinations
  • Angular 4.x 动态创建组件
  • Docker 笔记(2):Dockerfile
  • ES2017异步函数现已正式可用
  • HTTP请求重发
  • Netty 框架总结「ChannelHandler 及 EventLoop」
  • PHP变量
  • PHP面试之三:MySQL数据库
  • Spring Cloud Alibaba迁移指南(一):一行代码从 Hystrix 迁移到 Sentinel
  • 分享自己折腾多时的一套 vue 组件 --we-vue
  • 关于 Cirru Editor 存储格式
  • 技术发展面试
  • 聊聊flink的TableFactory
  • 如何在 Tornado 中实现 Middleware
  • 世界上最简单的无等待算法(getAndIncrement)
  • 微信小程序开发问题汇总
  • 用 vue 组件自定义 v-model, 实现一个 Tab 组件。
  • 原生 js 实现移动端 Touch 滑动反弹
  • 06-01 点餐小程序前台界面搭建
  • ​queue --- 一个同步的队列类​
  • ​第20课 在Android Native开发中加入新的C++类
  • ​软考-高级-系统架构设计师教程(清华第2版)【第20章 系统架构设计师论文写作要点(P717~728)-思维导图】​
  • #我与Java虚拟机的故事#连载18:JAVA成长之路
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (HAL)STM32F103C6T8——软件模拟I2C驱动0.96寸OLED屏幕
  • (LeetCode C++)盛最多水的容器
  • (pojstep1.1.2)2654(直叙式模拟)
  • (附源码)ssm高校志愿者服务系统 毕业设计 011648
  • (三)Hyperledger Fabric 1.1安装部署-chaincode测试
  • (四) 虚拟摄像头vivi体验
  • (四)JPA - JQPL 实现增删改查
  • (转)socket Aio demo
  • (转)项目管理杂谈-我所期望的新人
  • .bat批处理(八):各种形式的变量%0、%i、%%i、var、%var%、!var!的含义和区别
  • .net mvc actionresult 返回字符串_.NET架构师知识普及
  • .net Signalr 使用笔记
  • .NET WebClient 类下载部分文件会错误?可能是解压缩的锅
  • .net程序集学习心得
  • .NET命令行(CLI)常用命令
  • .net中的Queue和Stack