├── README.md ├── common └── common.go ├── conf └── conf.ini ├── frame ├── common.go ├── frame.pb.go └── frame.proto ├── session └── session.go ├── stream └── stream.go ├── test ├── client │ └── client.go └── server │ └── server.go └── vendor └── github.com ├── go-ini └── ini │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── README_ZH.md │ ├── error.go │ ├── ini.go │ ├── ini_test.go │ ├── key.go │ ├── key_test.go │ ├── parser.go │ ├── parser_test.go │ ├── section.go │ ├── section_test.go │ ├── struct.go │ ├── struct_test.go │ └── testdata │ ├── UTF-16-BE-BOM.ini │ ├── UTF-16-LE-BOM.ini │ ├── UTF-8-BOM.ini │ ├── aicc.ini │ └── conf.ini └── golang └── protobuf ├── .gitignore ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── Make.protobuf ├── Makefile ├── README.md ├── _conformance ├── Makefile ├── conformance.go └── conformance_proto │ ├── conformance.pb.go │ └── conformance.proto ├── jsonpb ├── jsonpb.go ├── jsonpb_test.go └── jsonpb_test_proto │ ├── Makefile │ ├── more_test_objects.pb.go │ ├── more_test_objects.proto │ ├── test_objects.pb.go │ └── test_objects.proto ├── proto ├── Makefile ├── all_test.go ├── any_test.go ├── clone.go ├── clone_test.go ├── decode.go ├── decode_test.go ├── encode.go ├── encode_test.go ├── equal.go ├── equal_test.go ├── extensions.go ├── extensions_test.go ├── lib.go ├── message_set.go ├── message_set_test.go ├── pointer_reflect.go ├── pointer_unsafe.go ├── properties.go ├── proto3_proto │ ├── proto3.pb.go │ └── proto3.proto ├── proto3_test.go ├── size2_test.go ├── size_test.go ├── testdata │ ├── Makefile │ ├── golden_test.go │ ├── test.pb.go │ └── test.proto ├── text.go ├── text_parser.go ├── text_parser_test.go └── text_test.go ├── protoc-gen-go ├── Makefile ├── descriptor │ ├── Makefile │ └── descriptor.pb.go ├── doc.go ├── generator │ ├── Makefile │ ├── generator.go │ └── name_test.go ├── grpc │ └── grpc.go ├── link_grpc.go ├── main.go ├── plugin │ ├── Makefile │ ├── plugin.pb.go │ └── plugin.pb.golden └── testdata │ ├── Makefile │ ├── extension_base.proto │ ├── extension_extra.proto │ ├── extension_test.go │ ├── extension_user.proto │ ├── grpc.proto │ ├── imp.pb.go.golden │ ├── imp.proto │ ├── imp2.proto │ ├── imp3.proto │ ├── main_test.go │ ├── multi │ ├── multi1.proto │ ├── multi2.proto │ └── multi3.proto │ ├── my_test │ ├── test.pb.go │ ├── test.pb.go.golden │ └── test.proto │ └── proto3.proto └── ptypes ├── any.go ├── any ├── any.pb.go └── any.proto ├── any_test.go ├── doc.go ├── duration.go ├── duration ├── duration.pb.go └── duration.proto ├── duration_test.go ├── empty ├── empty.pb.go └── empty.proto ├── regen.sh ├── struct ├── struct.pb.go └── struct.proto ├── timestamp.go ├── timestamp ├── timestamp.pb.go └── timestamp.proto ├── timestamp_test.go └── wrappers ├── wrappers.pb.go └── wrappers.proto /README.md: -------------------------------------------------------------------------------- 1 | **这是一道面试题** 2 | 3 | *使用golang的CSP思想,简单搭建一个tcp服务端及模拟客户端,要求合理使用到知识点:锁,组锁,协程,通道,接口,定时(超时),C/S通信需要使用protobuf结构。 4 | 模拟客户端至少需要完成连接,成功发送与接收一次协议,关闭连接一套完整通信。 5 | 6 | **说明** 7 | 8 | 1.格式:[2byte][2byte][1byte][data] 9 | -------------------------------- 10 | 前两2个是协议开头标志  后面2个是标识数据(data)长度(仅包括data的长度) 接着的1个是操作类型  data为真实数据 11 | -------------------------------------------------------------------------------- /common/common.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "errors" 5 | "github.com/go-ini/ini" 6 | "github.com/golang/protobuf/proto" 7 | "github.com/nicle-lin/golang-csp/frame" 8 | "github.com/nicle-lin/golang-csp/stream" 9 | "log" 10 | "strconv" 11 | "sync" 12 | ) 13 | 14 | var conf = "../../conf/conf.ini" 15 | 16 | type Result struct { 17 | person frame.Person //执行失败就为空,当optype为ADD时,解析结果存在此 18 | request frame.Request 19 | optype frame.OpType //命令执行成功与否已经包含于此 20 | } 21 | 22 | func ParseProtobuf(optype frame.OpType, data []byte) (newFrame Result, err error) { 23 | if optype == frame.ADD { 24 | err = proto.Unmarshal(data, &newFrame.person) 25 | } else if optype == frame.GET || optype == frame.DELETE { 26 | err = proto.Unmarshal(data, &newFrame.request) 27 | } else { 28 | log.Printf("opType is illegal:%d", optype) 29 | err = errors.New("opType is illegal") 30 | return 31 | } 32 | newFrame.optype = optype 33 | return 34 | } 35 | 36 | func ParseCmd(st stream.Stream) Result { 37 | st.ReadUint16() 38 | st.ReadUint16() 39 | op, _ := st.ReadByte() 40 | newFrame, err := ParseProtobuf(frame.OpType(op), st.DataSelect(st.Pos(), st.Size())) 41 | if err != nil { 42 | log.Printf("Parse Request fail:%s\n", err) 43 | return Result{} 44 | } 45 | return newFrame 46 | } 47 | 48 | func ExecuteCmd(result Result, confLock *sync.RWMutex) ([]byte, frame.OpType) { 49 | var re Result 50 | switch result.optype { 51 | case frame.GET: 52 | re = getResultFromConf(result, confLock) 53 | data, err := proto.Marshal(&re.person) 54 | if err != nil { 55 | log.Println(err) 56 | 57 | return nil, re.optype 58 | } 59 | return data, re.optype 60 | case frame.ADD: 61 | re = addResultToConf(result, confLock) 62 | case frame.DELETE: 63 | re = deleteResultFromConf(result, confLock) 64 | 65 | default: 66 | return nil, re.optype 67 | } 68 | data, err := proto.Marshal(&re.request) 69 | if err != nil { 70 | log.Println(err) 71 | return nil, re.optype 72 | } 73 | return data, re.optype 74 | 75 | } 76 | 77 | func addResultToConf(result Result, confLock *sync.RWMutex) Result { 78 | confLock.Lock() 79 | defer confLock.Unlock() 80 | cfg, err := ini.Load(conf) 81 | if err != nil { 82 | log.Println(err) 83 | result.optype |= frame.FAIL 84 | return result 85 | } 86 | section := "Person" + strconv.Itoa(int(result.person.GetId())) 87 | _, err = cfg.Section(section).NewKey("Id", strconv.Itoa(int(result.person.GetId()))) 88 | if err != nil { 89 | log.Println(err) 90 | result.optype |= frame.FAIL 91 | return result 92 | } 93 | 94 | _, err = cfg.Section(section).NewKey("Name", result.person.GetName()) 95 | if err != nil { 96 | log.Println(err) 97 | result.optype |= frame.FAIL 98 | return result 99 | } 100 | 101 | _, err = cfg.Section(section).NewKey("Age", strconv.Itoa(int(result.person.GetAge()))) 102 | if err != nil { 103 | log.Println(err) 104 | result.optype |= frame.FAIL 105 | return result 106 | } 107 | 108 | _, err = cfg.Section(section).NewKey("City", result.person.GetCity()) 109 | if err != nil { 110 | log.Println(err) 111 | result.optype |= frame.FAIL 112 | return result 113 | } 114 | 115 | if err := cfg.SaveTo(conf); err != nil { 116 | log.Println(err) 117 | result.optype |= frame.FAIL 118 | return result 119 | } 120 | result.optype |= frame.SUCCESS 121 | log.Printf("trying to Add Person whose id is %d success\n", result.person.GetId()) 122 | return result 123 | } 124 | 125 | func deleteResultFromConf(result Result, confLock *sync.RWMutex) Result { 126 | confLock.Lock() 127 | defer confLock.Unlock() 128 | cfg, err := ini.Load(conf) 129 | if err != nil { 130 | log.Println(err) 131 | result.optype |= frame.FAIL 132 | return result 133 | } 134 | section := "Person" + strconv.Itoa(int(result.request.GetId())) 135 | cfg.DeleteSection(section) 136 | if err := cfg.SaveTo(conf); err != nil { 137 | log.Println(err) 138 | result.optype |= frame.FAIL 139 | return result 140 | } 141 | log.Printf("trying to delete Person whose id is %d success\n", result.request.GetId()) 142 | result.optype |= frame.SUCCESS 143 | return result 144 | } 145 | 146 | func getResultFromConf(result Result, confLock *sync.RWMutex) Result { 147 | confLock.RLock() 148 | defer confLock.RUnlock() 149 | cfg, err := ini.Load(conf) 150 | if err != nil { 151 | log.Println(err) 152 | result.optype |= frame.FAIL 153 | return result 154 | } 155 | section := "Person" + strconv.Itoa(int(result.request.GetId())) 156 | if _, err := cfg.GetSection(section); err != nil { 157 | person := frame.Person{ 158 | Id: proto.Int32(0), 159 | Name: proto.String("doesn't exist"), 160 | Age: proto.Int32(0), 161 | City: proto.String("doesn't exist"), 162 | } 163 | result.person = person 164 | result.optype |= frame.FAIL 165 | log.Printf("trying to get Person whose id is %d fail,doesn't exist\n", result.request.GetId()) 166 | return result 167 | } 168 | 169 | id, _ := strconv.Atoi(cfg.Section(section).Key("Id").String()) 170 | age, _ := strconv.Atoi(cfg.Section(section).Key("Age").String()) 171 | person := frame.Person{ 172 | Id: proto.Int32(int32(id)), 173 | Name: proto.String(cfg.Section(section).Key("Name").String()), 174 | Age: proto.Int32(int32(age)), 175 | City: proto.String(cfg.Section(section).Key("City").String()), 176 | } 177 | result.person = person 178 | 179 | result.optype |= frame.SUCCESS 180 | log.Printf("trying to get Person whose id is %d success\n", result.request.GetId()) 181 | return result 182 | } 183 | -------------------------------------------------------------------------------- /conf/conf.ini: -------------------------------------------------------------------------------- 1 | [Host] 2 | host = 127.0.0.1:8989 3 | 4 | [Person5] 5 | Id = 5 6 | Name = kdhin 7 | Age = 45 8 | City = mkipy 9 | 10 | [Person6] 11 | Id = 6 12 | Name = ejkra 13 | Age = 15 14 | City = xqxbc 15 | 16 | [Person4] 17 | Id = 4 18 | Name = jsczl 19 | Age = 52 20 | City = pskrr 21 | 22 | -------------------------------------------------------------------------------- /frame/common.go: -------------------------------------------------------------------------------- 1 | package frame 2 | 3 | import ( 4 | "errors" 5 | "github.com/nicle-lin/golang-csp/stream" 6 | "log" 7 | ) 8 | 9 | /* 10 | * 格式:[2byte][2byte][1byte][data] 11 | * 前两2个是协议开头标志  后面2个是标识数据(data)长度(仅包括data的长度) 接着的1个是操作类型  data为真实数据 12 | */ 13 | 14 | type OpType byte //操作类型 15 | 16 | const ( 17 | //客户端用于向服务端查询 增加 删除信息的操作类型 18 | GET OpType = 1 //0000 0001 19 | ADD OpType = 2 //0000 0010 20 | DELETE OpType = 4 //0000 0100 21 | 22 | //服务端用于返回操作是否成功 23 | SUCCESS OpType = 8 //0000 1000 24 | FAIL OpType = 16 //0001 0000 25 | 26 | FrameHeaderLen = 5 27 | MaxFrameLen = 1024 //随便定一个长度,这长度包括FrameHeaderLen及data 28 | FrameFlag = 0xf3db //协议开头标志 29 | ) 30 | 31 | type Frame interface { 32 | //根据操作类型返回可用于发送的[]byte类型的数据 33 | BuildFrame() (frame []byte, err error) 34 | SetFrameData(data []byte) 35 | SetFrameOpType(opType OpType) 36 | } 37 | 38 | type frame struct { 39 | data []byte 40 | optype OpType 41 | } 42 | 43 | func NewFrame(data []byte, opType OpType) Frame { 44 | return &frame{ 45 | data: data, 46 | optype: opType, 47 | } 48 | } 49 | 50 | func (f *frame) SetFrameData(data []byte) { 51 | f.data = data 52 | } 53 | 54 | func (f *frame) SetFrameOpType(optype OpType) { 55 | f.optype = optype 56 | } 57 | 58 | /* 59 | * 格式:[2byte][2byte][1byte][data] 60 | * 前两2个是协议开头标志  后面2个是标识数据(data)长度 接着的1个是操作类型  data为真实数据 61 | */ 62 | func (f *frame) BuildFrame() (frame []byte, err error) { 63 | buf := make([]byte, FrameHeaderLen+len(f.data)) 64 | st := stream.NewLEStream(buf) 65 | err = st.WriteUint16(FrameFlag) 66 | checkError(err) 67 | err = st.WriteUint16(uint16(len(f.data))) 68 | checkError(err) 69 | err = st.WriteByte(byte(f.optype)) 70 | checkError(err) 71 | err = st.WriteBuff(f.data) 72 | checkError(err) 73 | frame = st.Data() 74 | return 75 | } 76 | 77 | //解析协议头部是否合法,如果合法返回接下来要接收的数据长度,不合法就返回0 78 | //传入参数必须是头部5个字节的长度 79 | func ParseHeaderFrame(frameHeader []byte) (length uint16, err error) { 80 | if len(frameHeader) != FrameHeaderLen { 81 | err = errors.New("frameHeader isn't equal FrameHeaderLen(5)") 82 | return 83 | } 84 | st := stream.NewLEStream(frameHeader) 85 | flag, _ := st.ReadUint16() 86 | if flag != FrameFlag { 87 | err = errors.New("flag isn't equal 0xf3db") 88 | return 89 | } 90 | 91 | length, _ = st.ReadUint16() 92 | if length+FrameHeaderLen > MaxFrameLen { 93 | err = errors.New("frame length over MaxFrameLen(1024byte)") 94 | return 95 | } 96 | 97 | op, _ := st.ReadByte() 98 | switch OpType(op) { 99 | case ADD: 100 | case GET: 101 | case DELETE: 102 | case SUCCESS: 103 | case FAIL: 104 | case ADD | SUCCESS: 105 | case DELETE | SUCCESS: 106 | case GET | SUCCESS: 107 | case ADD | FAIL: 108 | case DELETE | FAIL: 109 | case GET | FAIL: 110 | default: //所有都没匹配中说明不是合法的操作 111 | log.Printf("operation:%d", op) 112 | err = errors.New("operation is illegal") 113 | } 114 | return 115 | } 116 | 117 | func checkError(err error) { 118 | if err != nil { 119 | log.Fatal(err) 120 | 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /frame/frame.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: frame.proto 3 | 4 | /* 5 | Package frame is a generated protocol buffer package. 6 | 7 | It is generated from these files: 8 | frame.proto 9 | 10 | It has these top-level messages: 11 | Request 12 | Person 13 | */ 14 | package frame 15 | 16 | import proto "github.com/golang/protobuf/proto" 17 | import fmt "fmt" 18 | import math "math" 19 | 20 | // Reference imports to suppress errors if they are not otherwise used. 21 | var _ = proto.Marshal 22 | var _ = fmt.Errorf 23 | var _ = math.Inf 24 | 25 | // This is a compile-time assertion to ensure that this generated file 26 | // is compatible with the proto package it is being compiled against. 27 | // A compilation error at this line likely means your copy of the 28 | // proto package needs to be updated. 29 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 30 | 31 | type Request struct { 32 | Id *int32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` 33 | Message *string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` 34 | XXX_unrecognized []byte `json:"-"` 35 | } 36 | 37 | func (m *Request) Reset() { *m = Request{} } 38 | func (m *Request) String() string { return proto.CompactTextString(m) } 39 | func (*Request) ProtoMessage() {} 40 | func (*Request) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 41 | 42 | func (m *Request) GetId() int32 { 43 | if m != nil && m.Id != nil { 44 | return *m.Id 45 | } 46 | return 0 47 | } 48 | 49 | func (m *Request) GetMessage() string { 50 | if m != nil && m.Message != nil { 51 | return *m.Message 52 | } 53 | return "" 54 | } 55 | 56 | type Person struct { 57 | Id *int32 `protobuf:"varint,1,req,name=id,def=0" json:"id,omitempty"` 58 | Name *string `protobuf:"bytes,2,req,name=name,def=doesn't exist" json:"name,omitempty"` 59 | Age *int32 `protobuf:"varint,3,req,name=age,def=0" json:"age,omitempty"` 60 | City *string `protobuf:"bytes,4,req,name=city,def=doesn't exist" json:"city,omitempty"` 61 | XXX_unrecognized []byte `json:"-"` 62 | } 63 | 64 | func (m *Person) Reset() { *m = Person{} } 65 | func (m *Person) String() string { return proto.CompactTextString(m) } 66 | func (*Person) ProtoMessage() {} 67 | func (*Person) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } 68 | 69 | const Default_Person_Id int32 = 0 70 | const Default_Person_Name string = "doesn't exist" 71 | const Default_Person_Age int32 = 0 72 | const Default_Person_City string = "doesn't exist" 73 | 74 | func (m *Person) GetId() int32 { 75 | if m != nil && m.Id != nil { 76 | return *m.Id 77 | } 78 | return Default_Person_Id 79 | } 80 | 81 | func (m *Person) GetName() string { 82 | if m != nil && m.Name != nil { 83 | return *m.Name 84 | } 85 | return Default_Person_Name 86 | } 87 | 88 | func (m *Person) GetAge() int32 { 89 | if m != nil && m.Age != nil { 90 | return *m.Age 91 | } 92 | return Default_Person_Age 93 | } 94 | 95 | func (m *Person) GetCity() string { 96 | if m != nil && m.City != nil { 97 | return *m.City 98 | } 99 | return Default_Person_City 100 | } 101 | 102 | func init() { 103 | proto.RegisterType((*Request)(nil), "frame.Request") 104 | proto.RegisterType((*Person)(nil), "frame.Person") 105 | } 106 | 107 | func init() { proto.RegisterFile("frame.proto", fileDescriptor0) } 108 | 109 | var fileDescriptor0 = []byte{ 110 | // 160 bytes of a gzipped FileDescriptorProto 111 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0xcc, 0xb1, 0x0a, 0xc2, 0x30, 112 | 0x14, 0x85, 0x61, 0x92, 0xb6, 0x96, 0x5e, 0x51, 0x30, 0x2e, 0x19, 0x6b, 0x17, 0x33, 0x89, 0xe0, 113 | 0xd6, 0xa7, 0x90, 0xbc, 0x41, 0x31, 0x57, 0xc9, 0x90, 0x44, 0x73, 0xa3, 0xe8, 0xdb, 0x4b, 0x82, 114 | 0xdd, 0x1c, 0x7f, 0x0e, 0xdf, 0x81, 0xe5, 0x35, 0x4e, 0x0e, 0x0f, 0xf7, 0x18, 0x52, 0x10, 0x4d, 115 | 0x89, 0xe1, 0x04, 0xad, 0xc6, 0xc7, 0x13, 0x29, 0x89, 0x35, 0x70, 0x6b, 0x24, 0xeb, 0x99, 0x6a, 116 | 0x34, 0xb7, 0x46, 0x48, 0x68, 0x1d, 0x12, 0x4d, 0x37, 0x94, 0xbc, 0x67, 0xaa, 0xd3, 0x73, 0x0e, 117 | 0x2f, 0x58, 0x9c, 0x31, 0x52, 0xf0, 0x62, 0xf3, 0x33, 0x5c, 0x35, 0x23, 0x3b, 0x16, 0xb6, 0x83, 118 | 0xda, 0x4f, 0x2e, 0x1b, 0xae, 0xba, 0x71, 0x65, 0x02, 0x92, 0xdf, 0xa7, 0x1e, 0xdf, 0x96, 0x92, 119 | 0x2e, 0x93, 0xd8, 0x42, 0x95, 0x5f, 0xab, 0x99, 0xe5, 0xca, 0xee, 0x62, 0xd3, 0x47, 0xd6, 0x7f, 120 | 0x5d, 0x9e, 0xbe, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5b, 0x2b, 0x64, 0xed, 0xc1, 0x00, 0x00, 0x00, 121 | } 122 | -------------------------------------------------------------------------------- /frame/frame.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package frame; 3 | 4 | message Request{ 5 | optional int32 id = 1; //以id来标识具体是要查询,删除,增加哪一个Person 6 | optional string message = 2; 7 | } 8 | 9 | message Person 10 | { 11 | required int32 id = 1 [default = 0]; //操作类型为增加时,从客户端带过来的id不用管 12 | required string name = 2 [default = "doesn't exist"]; 13 | required int32 age = 3 [default = 0]; 14 | required string city =4 [default = "doesn't exist"]; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /session/session.go: -------------------------------------------------------------------------------- 1 | package session 2 | 3 | import ( 4 | "errors" 5 | "github.com/nicle-lin/golang-csp/frame" 6 | "github.com/nicle-lin/golang-csp/stream" 7 | "io" 8 | "net" 9 | ) 10 | 11 | type Session interface { 12 | //从网络中读取数据,读回来是一个完整协议的,不完整就返回失败 13 | //连接被对端关闭了就返回一个io.ErrUnexpectedEOF 14 | Read() (st stream.Stream, err error) 15 | //向网络中写入一段完整协议的数据 16 | //连接被对端关闭了就返回一个io.EOF 17 | Write(f frame.Frame) (n int, err error) 18 | //关闭conn 19 | Close() 20 | } 21 | 22 | type session struct { 23 | conn net.Conn 24 | } 25 | 26 | func NewSession(conn net.Conn) Session { 27 | return &session{conn: conn} 28 | } 29 | 30 | func (s *session) Read() (st stream.Stream, err error) { 31 | //分配frame头部长度的大小的空间 32 | frameHeader := make([]byte, frame.FrameHeaderLen) 33 | n, err := io.ReadFull(s.conn, frameHeader) 34 | if err != nil { 35 | return 36 | } 37 | if n != frame.FrameHeaderLen{ 38 | err = errors.New("not enough data to read") 39 | return 40 | } 41 | var dataLength uint16 42 | //校验收到的头部是否正确 43 | dataLength, err = frame.ParseHeaderFrame(frameHeader) 44 | if err != nil { 45 | return 46 | } 47 | 48 | //读取data 49 | data := make([]byte, dataLength) 50 | if _, err = io.ReadFull(s.conn, data); err != nil { 51 | return 52 | } 53 | 54 | //TODO: maybe there anther more effective,such as bytes.join 55 | newData := make([]byte, frame.FrameHeaderLen+dataLength) 56 | copy(newData, frameHeader) 57 | copy(newData[frame.FrameHeaderLen:], data) 58 | st = stream.NewLEStream(newData) 59 | return 60 | } 61 | 62 | func (s *session) Write(f frame.Frame) (n int, err error) { 63 | frame, err1 := f.BuildFrame() 64 | if err1 != nil { 65 | err = err1 66 | return 67 | } 68 | return s.conn.Write(frame) 69 | } 70 | 71 | func (s *session) Close() { 72 | s.conn.Close() 73 | } 74 | -------------------------------------------------------------------------------- /test/client/client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/go-ini/ini" 5 | "github.com/golang/protobuf/proto" 6 | "github.com/nicle-lin/golang-csp/frame" 7 | "github.com/nicle-lin/golang-csp/session" 8 | "io" 9 | "log" 10 | "math/rand" 11 | "net" 12 | "os" 13 | "time" 14 | ) 15 | 16 | var conf = "../../conf/conf.ini" 17 | var network, address string = "tcp", "127.0.0.1:8989" 18 | var opTypes = []frame.OpType{ 19 | frame.GET, 20 | frame.ADD, 21 | frame.DELETE, 22 | } 23 | 24 | func init() { 25 | //一开始就读文件,没有回锁也不会有竞争,因为压根没人来竞争 26 | conf := "../../conf/conf.ini" 27 | cfg, err := ini.Load(conf) 28 | if err != nil { 29 | log.Printf("can't get the network address from %s,\n error:%s", conf, err) 30 | log.Printf("set the network address:%s", address) 31 | } else { 32 | address = cfg.Section("Host").Key("host").String() 33 | } 34 | 35 | } 36 | func RandomNumber(number int32) int32 { 37 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 38 | return r.Int31n(number) 39 | } 40 | 41 | func RandomString(length int) string { 42 | bytes := []byte{'a','b','c','d','e','f','g','h','i', 43 | 'j','k','l','m','n','o','p','q','r', 44 | 's','t','u','v','w','x','y','z'} 45 | var result []byte 46 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 47 | for i := 0; i < length; i++ { 48 | result = append(result, bytes[r.Intn(len(bytes))]) 49 | } 50 | return string(result) 51 | } 52 | 53 | func write(opType frame.OpType, data []byte, se session.Session) { 54 | f := frame.NewFrame(data, opType) 55 | _, err := se.Write(f) 56 | if err != nil { 57 | log.Println("wirte error:", err) 58 | } 59 | } 60 | 61 | func start() { 62 | log.Println("trying to connect") 63 | conn, err := net.Dial(network, address) 64 | if err != nil { 65 | log.Println(err) 66 | return 67 | } 68 | log.Printf("connecting successfully(%s)", conn.RemoteAddr()) 69 | defer conn.Close() 70 | 71 | //for Get 72 | newRequest := &frame.Request{ 73 | Id: proto.Int32(RandomNumber(10)), 74 | Message: proto.String("Show me Person"), 75 | } 76 | dataGet, err := proto.Marshal(newRequest) 77 | if err != nil { 78 | log.Println(err) 79 | } 80 | 81 | //for Delete 82 | newRequest.Id = proto.Int32(RandomNumber(10)) 83 | newRequest.Message = proto.String("delete Person") 84 | dataDelete, err := proto.Marshal(newRequest) 85 | if err != nil { 86 | log.Println(err) 87 | } 88 | 89 | //for Add 90 | newPerson := &frame.Person{ 91 | Id: proto.Int32(RandomNumber(10)), 92 | Age: proto.Int32(RandomNumber(100)), 93 | Name: proto.String(RandomString(5)), 94 | City: proto.String(RandomString(5)), 95 | } 96 | dataAdd, err := proto.Marshal(newPerson) 97 | if err != nil { 98 | log.Println(err) 99 | } 100 | //用于判断Write Read是否完成了 101 | done := make(chan struct{}, 2) 102 | se := session.NewSession(conn) 103 | 104 | //Write 105 | go func() { 106 | for _, op := range opTypes { 107 | switch op { 108 | case frame.ADD: 109 | write(op, dataAdd, se) 110 | case frame.DELETE: 111 | write(op, dataDelete, se) 112 | default: //默认为GET 113 | write(op, dataGet, se) 114 | } 115 | } 116 | done <- struct{}{} 117 | }() 118 | //Read 119 | go func() { 120 | //因为只写了3次,所有只读3即可,然后关闭conn 121 | for i := 0; i < 3; i++ { 122 | st, err := se.Read() 123 | if err == io.ErrUnexpectedEOF { 124 | log.Println("connection has been closed by peer") 125 | break 126 | } else if err != nil { 127 | log.Println(err) 128 | break 129 | } 130 | 131 | st.ReadUint16() 132 | st.ReadUint16() 133 | optype, _ := st.ReadByte() 134 | op := frame.OpType(optype) 135 | PrintResult(op, st.DataSelect(st.Pos(), st.Size())) 136 | 137 | } 138 | done <- struct{}{} 139 | se.Close() 140 | }() 141 | <-done 142 | <-done 143 | } 144 | 145 | func PrintResult(op frame.OpType, data []byte) { 146 | var operate = "" 147 | 148 | switch { //此处 switch op{}是不正确的,因为判断应交给下面的case语句 149 | case (op & frame.ADD) == frame.ADD: 150 | operate = "Add" 151 | case op&frame.DELETE == frame.DELETE: 152 | operate = "Delete" 153 | case op&frame.GET == frame.GET: 154 | operate = "Get" 155 | newPerson := &frame.Person{} 156 | err := proto.Unmarshal(data, newPerson) 157 | if err != nil { 158 | log.Println(err) 159 | } 160 | log.Printf("Get the Person:\nID:%d\nName:%s\nAge:%d\nCity:%s\n", 161 | newPerson.GetId(), newPerson.GetName(), newPerson.GetAge(), newPerson.GetCity()) 162 | 163 | default: 164 | log.Printf("unknow operate:%+v\n", op) 165 | } 166 | switch { 167 | case op&frame.SUCCESS == frame.SUCCESS: 168 | log.Printf("execute operate %s success\n", operate) 169 | case op&frame.FAIL == frame.FAIL: 170 | log.Printf("execute operate %s fail\n", operate) 171 | default: 172 | log.Printf("unknow operate:%+v\n", op) 173 | } 174 | 175 | } 176 | 177 | func main() { 178 | 179 | go func() { 180 | select { 181 | case <-time.NewTimer(time.Second * 8).C: 182 | log.Println("time out, exit") 183 | os.Exit(1) 184 | } 185 | }() 186 | 187 | log.Println("start to connect") 188 | start() 189 | log.Println("All operation done") 190 | 191 | } 192 | -------------------------------------------------------------------------------- /test/server/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "github.com/go-ini/ini" 6 | "github.com/nicle-lin/golang-csp/common" 7 | "github.com/nicle-lin/golang-csp/frame" 8 | "github.com/nicle-lin/golang-csp/session" 9 | "io" 10 | "log" 11 | "net" 12 | "os" 13 | "os/signal" 14 | "sync" 15 | "syscall" 16 | "time" 17 | ) 18 | 19 | type Server interface { 20 | //开始监听等一系列后续动作 21 | Start() 22 | //通知所有的goroutines退出 23 | Stop() 24 | } 25 | 26 | type server struct { 27 | confLock *sync.RWMutex //读写配置用到的锁 28 | exitCh chan struct{} //收到Signal后通知所有goroutines退出 29 | waitGroup *sync.WaitGroup //等待所有的goroutines退出 30 | context context.Context //用于通知所有子goroutines cancel 31 | cancel context.CancelFunc //用于通知所有子goroutines cancel 32 | } 33 | 34 | func NewServer() Server { 35 | //用于通知所有子goroutines cancel 36 | ctx, cancel := context.WithCancel(context.Background()) 37 | return &server{ 38 | confLock: new(sync.RWMutex), 39 | exitCh: make(chan struct{}), 40 | waitGroup: &sync.WaitGroup{}, 41 | context: ctx, 42 | cancel: cancel, 43 | } 44 | } 45 | 46 | //从socket里把数据读出来,并解析出命令,然后执行命令,把命令结果通过channel发送给 47 | //writeLoop()函数去发送数据 48 | func (srv *server) readLoop(se session.Session, resultCh chan<- interface{}, done chan<- struct{}) { 49 | srv.waitGroup.Add(1) 50 | defer func() { 51 | close(resultCh) //只有发送方才可以关闭通道,要不然会引起panic 52 | done <- struct{}{} 53 | srv.waitGroup.Done() 54 | }() 55 | //只要客户端不关闭连接就会一直等待数据,当然也可以设置服务端超时机制,主动关闭连接 56 | for { 57 | select { 58 | case <-srv.context.Done(): 59 | break 60 | default: 61 | 62 | } 63 | //从socket读取 64 | st, err := se.Read() 65 | if err == io.ErrUnexpectedEOF || err == io.EOF { 66 | log.Println("connection has been closed by peer") 67 | break 68 | } else if err != nil { 69 | log.Println("read error:", err) 70 | break 71 | } 72 | //分析socket读出来数据,返回一个Result结构体 73 | result := common.ParseCmd(st) 74 | //执行命令 75 | data, optype := common.ExecuteCmd(result, srv.confLock) 76 | //通过channel发送结果给writeLoop() 77 | resultCh <- data 78 | resultCh <- optype 79 | 80 | } 81 | 82 | return 83 | 84 | } 85 | 86 | //从channel里读数据,所有把数据发送到socket里 87 | func (srv *server) writeLoop(se session.Session, resultCh <-chan interface{}, done chan<- struct{}) { 88 | srv.waitGroup.Add(1) 89 | defer func() { 90 | done <- struct{}{} 91 | se.Close() 92 | srv.waitGroup.Done() 93 | }() 94 | f := frame.NewFrame(nil, frame.SUCCESS) 95 | for { 96 | select { 97 | case <-srv.context.Done(): 98 | break 99 | default: 100 | 101 | } 102 | for i := 0; i < 2; i++ { 103 | elem, isClosed := <-resultCh 104 | if !isClosed { 105 | return 106 | } 107 | switch elem.(type) { 108 | case []byte: 109 | data, ok := interface{}(elem).([]byte) 110 | if ok { 111 | f.SetFrameData(data) 112 | } else { 113 | log.Println("change interface{} to []byte fail") 114 | } 115 | 116 | case frame.OpType: 117 | optype, ok := interface{}(elem).(frame.OpType) 118 | if ok { 119 | 120 | f.SetFrameOpType(optype) 121 | 122 | } else { 123 | log.Println("change interface{} to OpType fail") 124 | } 125 | 126 | } 127 | } 128 | 129 | //发送从channel中读取的数据,发送到socket 130 | _, err := se.Write(f) 131 | if err == io.EOF || err == io.ErrClosedPipe { 132 | log.Println("connection has been closed by peer") 133 | break 134 | } else if err != nil { 135 | log.Println("write error:", err) 136 | break 137 | } 138 | 139 | } 140 | return 141 | 142 | } 143 | 144 | func (srv *server) newConn(conn net.Conn) { 145 | srv.waitGroup.Add(1) 146 | 147 | //如果3秒都没有读到或写完说明网络太差了 148 | conn.SetReadDeadline(time.Now().Add(time.Second * 3)) 149 | se := session.NewSession(conn) 150 | 151 | done := make(chan struct{}, 2) 152 | defer func() { 153 | close(done) 154 | se.Close() 155 | srv.waitGroup.Done() 156 | }() 157 | //用于从readLoop的结果发送到writeLoop 158 | resultCh := make(chan interface{}, 2) 159 | go srv.readLoop(se, resultCh, done) 160 | go srv.writeLoop(se, resultCh, done) 161 | <-done 162 | <-done 163 | log.Println("closed connection.........done") 164 | return 165 | 166 | } 167 | 168 | func (srv *server) Start() { 169 | go func() { 170 | <-srv.exitCh //收到退出信号 171 | srv.cancel() //取消所有goroutines 172 | }() 173 | 174 | l, err := net.Listen(network, address) 175 | if err != nil { 176 | log.Println(err) 177 | } 178 | defer l.Close() 179 | log.Printf("Listening on %s\n", address) 180 | 181 | for { 182 | select { 183 | case <-srv.exitCh: //收到退出信号 184 | srv.cancel() //取消所有goroutines 185 | return 186 | default: 187 | 188 | } 189 | log.Println("waiting for a new connection.....") 190 | conn, err := l.Accept() 191 | if err != nil { 192 | log.Println(err) 193 | } 194 | //新的连接到来开始处理 195 | log.Printf("a new connection coming(%s)....", conn.RemoteAddr()) 196 | //每来一个新的连接就启用一个新的goroutine处理 197 | go srv.newConn(conn) 198 | } 199 | 200 | } 201 | 202 | //收到退出信号调用此函数 203 | func (srv *server) Stop() { 204 | close(srv.exitCh) 205 | srv.waitGroup.Wait() //等待所有goroutines优雅退出 206 | log.Println("--------------the program has been exited") 207 | } 208 | 209 | var network, address = "tcp", "127.0.0.1:8989" 210 | 211 | func init() { 212 | //一开始就读文件,没有回锁也不会有竞争,因为压根没人来竞争 213 | conf := "../../conf/conf.ini" 214 | cfg, err := ini.Load(conf) 215 | if err != nil { 216 | log.Printf("can't get the network address from %s,\n error:%s", conf, err) 217 | log.Printf("set the network address:%s", address) 218 | } else { 219 | address = cfg.Section("Host").Key("host").String() 220 | } 221 | 222 | } 223 | 224 | func main() { 225 | srv := NewServer() 226 | go srv.Start() 227 | 228 | SigRecv := make(chan os.Signal, 1) 229 | //catch ct+c signal 230 | signal.Notify(SigRecv, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) 231 | sig := <-SigRecv 232 | log.Printf("catch signal(%s) to exit\n", sig.String()) 233 | srv.Stop() //开始通知退出 234 | } 235 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/.gitignore: -------------------------------------------------------------------------------- 1 | testdata/conf_out.ini 2 | ini.sublime-project 3 | ini.sublime-workspace 4 | testdata/conf_reflect.ini 5 | .idea 6 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.4.x 5 | - 1.5.x 6 | - 1.6.x 7 | - 1.7.x 8 | - master 9 | 10 | script: 11 | - go get golang.org/x/tools/cmd/cover 12 | - go get github.com/smartystreets/goconvey 13 | - go test -v -cover -race 14 | 15 | notifications: 16 | email: 17 | - u@gogs.io 18 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build test bench vet 2 | 3 | build: vet bench 4 | 5 | test: 6 | go test -v -cover -race 7 | 8 | bench: 9 | go test -v -cover -race -test.bench=. -test.benchmem 10 | 11 | vet: 12 | go vet 13 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | type ErrDelimiterNotFound struct { 22 | Line string 23 | } 24 | 25 | func IsErrDelimiterNotFound(err error) bool { 26 | _, ok := err.(ErrDelimiterNotFound) 27 | return ok 28 | } 29 | 30 | func (err ErrDelimiterNotFound) Error() string { 31 | return fmt.Sprintf("key-value delimiter not found: %s", err.Line) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/parser_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "testing" 19 | 20 | . "github.com/smartystreets/goconvey/convey" 21 | ) 22 | 23 | func Test_BOM(t *testing.T) { 24 | Convey("Test handling BOM", t, func() { 25 | Convey("UTF-8-BOM", func() { 26 | cfg, err := Load("testdata/UTF-8-BOM.ini") 27 | So(err, ShouldBeNil) 28 | So(cfg, ShouldNotBeNil) 29 | 30 | So(cfg.Section("author").Key("E-MAIL").String(), ShouldEqual, "u@gogs.io") 31 | }) 32 | 33 | Convey("UTF-16-LE-BOM", func() { 34 | cfg, err := Load("testdata/UTF-16-LE-BOM.ini") 35 | So(err, ShouldBeNil) 36 | So(cfg, ShouldNotBeNil) 37 | }) 38 | 39 | Convey("UTF-16-BE-BOM", func() { 40 | }) 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/section_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "strings" 19 | "testing" 20 | 21 | . "github.com/smartystreets/goconvey/convey" 22 | ) 23 | 24 | func Test_Section(t *testing.T) { 25 | Convey("Test CRD sections", t, func() { 26 | cfg, err := Load([]byte(_CONF_DATA), "testdata/conf.ini") 27 | So(err, ShouldBeNil) 28 | So(cfg, ShouldNotBeNil) 29 | 30 | Convey("Get section strings", func() { 31 | So(strings.Join(cfg.SectionStrings(), ","), ShouldEqual, "DEFAULT,author,package,package.sub,features,types,array,note,comments,advance") 32 | }) 33 | 34 | Convey("Delete a section", func() { 35 | cfg.DeleteSection("") 36 | So(cfg.SectionStrings()[0], ShouldNotEqual, DEFAULT_SECTION) 37 | }) 38 | 39 | Convey("Create new sections", func() { 40 | cfg.NewSections("test", "test2") 41 | _, err := cfg.GetSection("test") 42 | So(err, ShouldBeNil) 43 | _, err = cfg.GetSection("test2") 44 | So(err, ShouldBeNil) 45 | }) 46 | }) 47 | } 48 | 49 | func Test_SectionRaw(t *testing.T) { 50 | Convey("Test section raw string", t, func() { 51 | cfg, err := LoadSources( 52 | LoadOptions{ 53 | Insensitive: true, 54 | UnparseableSections: []string{"core_lesson", "comments"}, 55 | }, 56 | "testdata/aicc.ini") 57 | So(err, ShouldBeNil) 58 | So(cfg, ShouldNotBeNil) 59 | 60 | Convey("Get section strings", func() { 61 | So(strings.Join(cfg.SectionStrings(), ","), ShouldEqual, "DEFAULT,core,core_lesson,comments") 62 | }) 63 | 64 | Convey("Validate non-raw section", func() { 65 | val, err := cfg.Section("core").GetKey("lesson_status") 66 | So(err, ShouldBeNil) 67 | So(val.String(), ShouldEqual, "C") 68 | }) 69 | 70 | Convey("Validate raw section", func() { 71 | So(cfg.Section("core_lesson").Body(), ShouldEqual, `my lesson state data – 1111111111111111111000000000000000001110000 72 | 111111111111111111100000000000111000000000 – end my lesson state data`) 73 | }) 74 | }) 75 | } -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/UTF-16-BE-BOM.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicle-lin/golang-csp/662e6b977a15fcc580ad0c1a736bf5b40225975f/vendor/github.com/go-ini/ini/testdata/UTF-16-BE-BOM.ini -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/UTF-16-LE-BOM.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicle-lin/golang-csp/662e6b977a15fcc580ad0c1a736bf5b40225975f/vendor/github.com/go-ini/ini/testdata/UTF-16-LE-BOM.ini -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/UTF-8-BOM.ini: -------------------------------------------------------------------------------- 1 | [author] 2 | E-MAIL = u@gogs.io -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/aicc.ini: -------------------------------------------------------------------------------- 1 | [Core] 2 | Lesson_Location = 87 3 | Lesson_Status = C 4 | Score = 3 5 | Time = 00:02:30 6 | 7 | [CORE_LESSON] 8 | my lesson state data – 1111111111111111111000000000000000001110000 9 | 111111111111111111100000000000111000000000 – end my lesson state data 10 | [COMMENTS] 11 | <1> This slide has the fuel listed in the wrong units 12 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/testdata/conf.ini: -------------------------------------------------------------------------------- 1 | [author] 2 | E-MAIL = u@gogs.io -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.[568ao] 3 | *.ao 4 | *.so 5 | *.pyc 6 | ._* 7 | .nfs.* 8 | [568a].out 9 | *~ 10 | *.orig 11 | core 12 | _obj 13 | _test 14 | _testmain.go 15 | protoc-gen-go/testdata/multi/*.pb.go 16 | _conformance/_conformance 17 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/Make.protobuf: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Includable Makefile to add a rule for generating .pb.go files from .proto files 33 | # (Google protocol buffer descriptions). 34 | # Typical use if myproto.proto is a file in package mypackage in this directory: 35 | # 36 | # include $(GOROOT)/src/pkg/github.com/golang/protobuf/Make.protobuf 37 | 38 | %.pb.go: %.proto 39 | protoc --go_out=. $< 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | 33 | all: install 34 | 35 | install: 36 | go install ./proto ./jsonpb ./ptypes 37 | go install ./protoc-gen-go 38 | 39 | test: 40 | go test ./proto ./jsonpb ./ptypes 41 | make -C protoc-gen-go/testdata test 42 | 43 | clean: 44 | go clean ./... 45 | 46 | nuke: 47 | go clean -i ./... 48 | 49 | regenerate: 50 | make -C protoc-gen-go/descriptor regenerate 51 | make -C protoc-gen-go/plugin regenerate 52 | make -C protoc-gen-go/testdata regenerate 53 | make -C proto/testdata regenerate 54 | make -C jsonpb/jsonpb_test_proto regenerate 55 | make -C _conformance regenerate 56 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/_conformance/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2016 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | regenerate: 33 | protoc --go_out=Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers,Mgoogle/protobuf/field_mask.proto=google.golang.org/genproto/protobuf:. conformance_proto/conformance.proto 34 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/_conformance/conformance.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // conformance implements the conformance test subprocess protocol as 33 | // documented in conformance.proto. 34 | package main 35 | 36 | import ( 37 | "encoding/binary" 38 | "fmt" 39 | "io" 40 | "os" 41 | 42 | pb "github.com/golang/protobuf/_conformance/conformance_proto" 43 | "github.com/golang/protobuf/jsonpb" 44 | "github.com/golang/protobuf/proto" 45 | ) 46 | 47 | func main() { 48 | var sizeBuf [4]byte 49 | inbuf := make([]byte, 0, 4096) 50 | outbuf := proto.NewBuffer(nil) 51 | for { 52 | if _, err := io.ReadFull(os.Stdin, sizeBuf[:]); err == io.EOF { 53 | break 54 | } else if err != nil { 55 | fmt.Fprintln(os.Stderr, "go conformance: read request:", err) 56 | os.Exit(1) 57 | } 58 | size := binary.LittleEndian.Uint32(sizeBuf[:]) 59 | if int(size) > cap(inbuf) { 60 | inbuf = make([]byte, size) 61 | } 62 | inbuf = inbuf[:size] 63 | if _, err := io.ReadFull(os.Stdin, inbuf); err != nil { 64 | fmt.Fprintln(os.Stderr, "go conformance: read request:", err) 65 | os.Exit(1) 66 | } 67 | 68 | req := new(pb.ConformanceRequest) 69 | if err := proto.Unmarshal(inbuf, req); err != nil { 70 | fmt.Fprintln(os.Stderr, "go conformance: parse request:", err) 71 | os.Exit(1) 72 | } 73 | res := handle(req) 74 | 75 | if err := outbuf.Marshal(res); err != nil { 76 | fmt.Fprintln(os.Stderr, "go conformance: marshal response:", err) 77 | os.Exit(1) 78 | } 79 | binary.LittleEndian.PutUint32(sizeBuf[:], uint32(len(outbuf.Bytes()))) 80 | if _, err := os.Stdout.Write(sizeBuf[:]); err != nil { 81 | fmt.Fprintln(os.Stderr, "go conformance: write response:", err) 82 | os.Exit(1) 83 | } 84 | if _, err := os.Stdout.Write(outbuf.Bytes()); err != nil { 85 | fmt.Fprintln(os.Stderr, "go conformance: write response:", err) 86 | os.Exit(1) 87 | } 88 | outbuf.Reset() 89 | } 90 | } 91 | 92 | var jsonMarshaler = jsonpb.Marshaler{ 93 | OrigName: true, 94 | } 95 | 96 | func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse { 97 | var err error 98 | var msg pb.TestAllTypes 99 | switch p := req.Payload.(type) { 100 | case *pb.ConformanceRequest_ProtobufPayload: 101 | err = proto.Unmarshal(p.ProtobufPayload, &msg) 102 | case *pb.ConformanceRequest_JsonPayload: 103 | err = jsonpb.UnmarshalString(p.JsonPayload, &msg) 104 | if err != nil && err.Error() == "unmarshaling Any not supported yet" { 105 | return &pb.ConformanceResponse{ 106 | Result: &pb.ConformanceResponse_Skipped{ 107 | Skipped: err.Error(), 108 | }, 109 | } 110 | } 111 | default: 112 | return &pb.ConformanceResponse{ 113 | Result: &pb.ConformanceResponse_RuntimeError{ 114 | RuntimeError: "unknown request payload type", 115 | }, 116 | } 117 | } 118 | if err != nil { 119 | return &pb.ConformanceResponse{ 120 | Result: &pb.ConformanceResponse_ParseError{ 121 | ParseError: err.Error(), 122 | }, 123 | } 124 | } 125 | switch req.RequestedOutputFormat { 126 | case pb.WireFormat_PROTOBUF: 127 | p, err := proto.Marshal(&msg) 128 | if err != nil { 129 | return &pb.ConformanceResponse{ 130 | Result: &pb.ConformanceResponse_SerializeError{ 131 | SerializeError: err.Error(), 132 | }, 133 | } 134 | } 135 | return &pb.ConformanceResponse{ 136 | Result: &pb.ConformanceResponse_ProtobufPayload{ 137 | ProtobufPayload: p, 138 | }, 139 | } 140 | case pb.WireFormat_JSON: 141 | p, err := jsonMarshaler.MarshalToString(&msg) 142 | if err != nil { 143 | return &pb.ConformanceResponse{ 144 | Result: &pb.ConformanceResponse_SerializeError{ 145 | SerializeError: err.Error(), 146 | }, 147 | } 148 | } 149 | return &pb.ConformanceResponse{ 150 | Result: &pb.ConformanceResponse_JsonPayload{ 151 | JsonPayload: p, 152 | }, 153 | } 154 | default: 155 | return &pb.ConformanceResponse{ 156 | Result: &pb.ConformanceResponse_RuntimeError{ 157 | RuntimeError: "unknown output format", 158 | }, 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2015 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | regenerate: 33 | protoc --go_out=Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any,Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration,Mgoogle/protobuf/struct.proto=github.com/golang/protobuf/ptypes/struct,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers:. *.proto 34 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto3"; 33 | 34 | package jsonpb; 35 | 36 | message Simple3 { 37 | double dub = 1; 38 | } 39 | 40 | enum Numeral { 41 | UNKNOWN = 0; 42 | ARABIC = 1; 43 | ROMAN = 2; 44 | } 45 | 46 | message Mappy { 47 | map nummy = 1; 48 | map strry = 2; 49 | map objjy = 3; 50 | map buggy = 4; 51 | map booly = 5; 52 | map enumy = 6; 53 | map s32booly = 7; 54 | map s64booly = 8; 55 | map u32booly = 9; 56 | map u64booly = 10; 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | import "google/protobuf/any.proto"; 35 | import "google/protobuf/duration.proto"; 36 | import "google/protobuf/struct.proto"; 37 | import "google/protobuf/timestamp.proto"; 38 | import "google/protobuf/wrappers.proto"; 39 | 40 | package jsonpb; 41 | 42 | // Test message for holding primitive types. 43 | message Simple { 44 | optional bool o_bool = 1; 45 | optional int32 o_int32 = 2; 46 | optional int64 o_int64 = 3; 47 | optional uint32 o_uint32 = 4; 48 | optional uint64 o_uint64 = 5; 49 | optional sint32 o_sint32 = 6; 50 | optional sint64 o_sint64 = 7; 51 | optional float o_float = 8; 52 | optional double o_double = 9; 53 | optional string o_string = 10; 54 | optional bytes o_bytes = 11; 55 | } 56 | 57 | // Test message for holding repeated primitives. 58 | message Repeats { 59 | repeated bool r_bool = 1; 60 | repeated int32 r_int32 = 2; 61 | repeated int64 r_int64 = 3; 62 | repeated uint32 r_uint32 = 4; 63 | repeated uint64 r_uint64 = 5; 64 | repeated sint32 r_sint32 = 6; 65 | repeated sint64 r_sint64 = 7; 66 | repeated float r_float = 8; 67 | repeated double r_double = 9; 68 | repeated string r_string = 10; 69 | repeated bytes r_bytes = 11; 70 | } 71 | 72 | // Test message for holding enums and nested messages. 73 | message Widget { 74 | enum Color { 75 | RED = 0; 76 | GREEN = 1; 77 | BLUE = 2; 78 | }; 79 | optional Color color = 1; 80 | repeated Color r_color = 2; 81 | 82 | optional Simple simple = 10; 83 | repeated Simple r_simple = 11; 84 | 85 | optional Repeats repeats = 20; 86 | repeated Repeats r_repeats = 21; 87 | } 88 | 89 | message Maps { 90 | map m_int64_str = 1; 91 | map m_bool_simple = 2; 92 | } 93 | 94 | message MsgWithOneof { 95 | oneof union { 96 | string title = 1; 97 | int64 salary = 2; 98 | string Country = 3; 99 | string home_address = 4; 100 | } 101 | } 102 | 103 | message Real { 104 | optional double value = 1; 105 | extensions 100 to max; 106 | } 107 | 108 | extend Real { 109 | optional string name = 124; 110 | } 111 | 112 | message Complex { 113 | extend Real { 114 | optional Complex real_extension = 123; 115 | } 116 | optional double imaginary = 1; 117 | extensions 100 to max; 118 | } 119 | 120 | message KnownTypes { 121 | optional google.protobuf.Any an = 14; 122 | optional google.protobuf.Duration dur = 1; 123 | optional google.protobuf.Struct st = 12; 124 | optional google.protobuf.Timestamp ts = 2; 125 | 126 | optional google.protobuf.DoubleValue dbl = 3; 127 | optional google.protobuf.FloatValue flt = 4; 128 | optional google.protobuf.Int64Value i64 = 5; 129 | optional google.protobuf.UInt64Value u64 = 6; 130 | optional google.protobuf.Int32Value i32 = 7; 131 | optional google.protobuf.UInt32Value u32 = 8; 132 | optional google.protobuf.BoolValue bool = 9; 133 | optional google.protobuf.StringValue str = 10; 134 | optional google.protobuf.BytesValue bytes = 11; 135 | } 136 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/encode_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto_test 33 | 34 | import ( 35 | "strconv" 36 | "testing" 37 | 38 | "github.com/golang/protobuf/proto" 39 | tpb "github.com/golang/protobuf/proto/proto3_proto" 40 | "github.com/golang/protobuf/ptypes" 41 | ) 42 | 43 | var ( 44 | blackhole []byte 45 | ) 46 | 47 | // BenchmarkAny creates increasingly large arbitrary Any messages. The type is always the 48 | // same. 49 | func BenchmarkAny(b *testing.B) { 50 | data := make([]byte, 1<<20) 51 | quantum := 1 << 10 52 | for i := uint(0); i <= 10; i++ { 53 | b.Run(strconv.Itoa(quantum< terrain = 10; 61 | testdata.SubDefaults proto2_field = 11; 62 | map proto2_value = 13; 63 | 64 | google.protobuf.Any anything = 14; 65 | repeated google.protobuf.Any many_things = 15; 66 | 67 | Message submessage = 17; 68 | repeated Message children = 18; 69 | } 70 | 71 | message Nested { 72 | string bunny = 1; 73 | bool cute = 2; 74 | } 75 | 76 | message MessageWithMap { 77 | map byte_mapping = 1; 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/proto3_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto_test 33 | 34 | import ( 35 | "testing" 36 | 37 | "github.com/golang/protobuf/proto" 38 | pb "github.com/golang/protobuf/proto/proto3_proto" 39 | tpb "github.com/golang/protobuf/proto/testdata" 40 | ) 41 | 42 | func TestProto3ZeroValues(t *testing.T) { 43 | tests := []struct { 44 | desc string 45 | m proto.Message 46 | }{ 47 | {"zero message", &pb.Message{}}, 48 | {"empty bytes field", &pb.Message{Data: []byte{}}}, 49 | } 50 | for _, test := range tests { 51 | b, err := proto.Marshal(test.m) 52 | if err != nil { 53 | t.Errorf("%s: proto.Marshal: %v", test.desc, err) 54 | continue 55 | } 56 | if len(b) > 0 { 57 | t.Errorf("%s: Encoding is non-empty: %q", test.desc, b) 58 | } 59 | } 60 | } 61 | 62 | func TestRoundTripProto3(t *testing.T) { 63 | m := &pb.Message{ 64 | Name: "David", // (2 | 1<<3): 0x0a 0x05 "David" 65 | Hilarity: pb.Message_PUNS, // (0 | 2<<3): 0x10 0x01 66 | HeightInCm: 178, // (0 | 3<<3): 0x18 0xb2 0x01 67 | Data: []byte("roboto"), // (2 | 4<<3): 0x20 0x06 "roboto" 68 | ResultCount: 47, // (0 | 7<<3): 0x38 0x2f 69 | TrueScotsman: true, // (0 | 8<<3): 0x40 0x01 70 | Score: 8.1, // (5 | 9<<3): 0x4d <8.1> 71 | 72 | Key: []uint64{1, 0xdeadbeef}, 73 | Nested: &pb.Nested{ 74 | Bunny: "Monty", 75 | }, 76 | } 77 | t.Logf(" m: %v", m) 78 | 79 | b, err := proto.Marshal(m) 80 | if err != nil { 81 | t.Fatalf("proto.Marshal: %v", err) 82 | } 83 | t.Logf(" b: %q", b) 84 | 85 | m2 := new(pb.Message) 86 | if err := proto.Unmarshal(b, m2); err != nil { 87 | t.Fatalf("proto.Unmarshal: %v", err) 88 | } 89 | t.Logf("m2: %v", m2) 90 | 91 | if !proto.Equal(m, m2) { 92 | t.Errorf("proto.Equal returned false:\n m: %v\nm2: %v", m, m2) 93 | } 94 | } 95 | 96 | func TestProto3SetDefaults(t *testing.T) { 97 | in := &pb.Message{ 98 | Terrain: map[string]*pb.Nested{ 99 | "meadow": new(pb.Nested), 100 | }, 101 | Proto2Field: new(tpb.SubDefaults), 102 | Proto2Value: map[string]*tpb.SubDefaults{ 103 | "badlands": new(tpb.SubDefaults), 104 | }, 105 | } 106 | 107 | got := proto.Clone(in).(*pb.Message) 108 | proto.SetDefaults(got) 109 | 110 | // There are no defaults in proto3. Everything should be the zero value, but 111 | // we need to remember to set defaults for nested proto2 messages. 112 | want := &pb.Message{ 113 | Terrain: map[string]*pb.Nested{ 114 | "meadow": new(pb.Nested), 115 | }, 116 | Proto2Field: &tpb.SubDefaults{N: proto.Int64(7)}, 117 | Proto2Value: map[string]*tpb.SubDefaults{ 118 | "badlands": &tpb.SubDefaults{N: proto.Int64(7)}, 119 | }, 120 | } 121 | 122 | if !proto.Equal(got, want) { 123 | t.Errorf("with in = %v\nproto.SetDefaults(in) =>\ngot %v\nwant %v", in, got, want) 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/size2_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto 33 | 34 | import ( 35 | "testing" 36 | ) 37 | 38 | // This is a separate file and package from size_test.go because that one uses 39 | // generated messages and thus may not be in package proto without having a circular 40 | // dependency, whereas this file tests unexported details of size.go. 41 | 42 | func TestVarintSize(t *testing.T) { 43 | // Check the edge cases carefully. 44 | testCases := []struct { 45 | n uint64 46 | size int 47 | }{ 48 | {0, 1}, 49 | {1, 1}, 50 | {127, 1}, 51 | {128, 2}, 52 | {16383, 2}, 53 | {16384, 3}, 54 | {1<<63 - 1, 9}, 55 | {1 << 63, 10}, 56 | } 57 | for _, tc := range testCases { 58 | size := sizeVarint(tc.n) 59 | if size != tc.size { 60 | t.Errorf("sizeVarint(%d) = %d, want %d", tc.n, size, tc.size) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/testdata/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | 33 | include ../../Make.protobuf 34 | 35 | all: regenerate 36 | 37 | regenerate: 38 | rm -f test.pb.go 39 | make test.pb.go 40 | 41 | # The following rules are just aids to development. Not needed for typical testing. 42 | 43 | diff: regenerate 44 | git diff test.pb.go 45 | 46 | restore: 47 | cp test.pb.go.golden test.pb.go 48 | 49 | preserve: 50 | cp test.pb.go test.pb.go.golden 51 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/testdata/golden_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // Verify that the compiler output for test.proto is unchanged. 33 | 34 | package testdata 35 | 36 | import ( 37 | "crypto/sha1" 38 | "fmt" 39 | "io/ioutil" 40 | "os" 41 | "os/exec" 42 | "path/filepath" 43 | "testing" 44 | ) 45 | 46 | // sum returns in string form (for easy comparison) the SHA-1 hash of the named file. 47 | func sum(t *testing.T, name string) string { 48 | data, err := ioutil.ReadFile(name) 49 | if err != nil { 50 | t.Fatal(err) 51 | } 52 | t.Logf("sum(%q): length is %d", name, len(data)) 53 | hash := sha1.New() 54 | _, err = hash.Write(data) 55 | if err != nil { 56 | t.Fatal(err) 57 | } 58 | return fmt.Sprintf("% x", hash.Sum(nil)) 59 | } 60 | 61 | func run(t *testing.T, name string, args ...string) { 62 | cmd := exec.Command(name, args...) 63 | cmd.Stdin = os.Stdin 64 | cmd.Stdout = os.Stdout 65 | cmd.Stderr = os.Stderr 66 | err := cmd.Run() 67 | if err != nil { 68 | t.Fatal(err) 69 | } 70 | } 71 | 72 | func TestGolden(t *testing.T) { 73 | // Compute the original checksum. 74 | goldenSum := sum(t, "test.pb.go") 75 | // Run the proto compiler. 76 | run(t, "protoc", "--go_out="+os.TempDir(), "test.proto") 77 | newFile := filepath.Join(os.TempDir(), "test.pb.go") 78 | defer os.Remove(newFile) 79 | // Compute the new checksum. 80 | newSum := sum(t, newFile) 81 | // Verify 82 | if newSum != goldenSum { 83 | run(t, "diff", "-u", "test.pb.go", newFile) 84 | t.Fatal("Code generated by protoc-gen-go has changed; update test.pb.go") 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | test: 33 | cd testdata && make test 34 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Not stored here, but descriptor.proto is in https://github.com/google/protobuf/ 33 | # at src/google/protobuf/descriptor.proto 34 | regenerate: 35 | echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION 36 | protoc --go_out=. -I$(HOME)/src/protobuf/src $(HOME)/src/protobuf/src/google/protobuf/descriptor.proto && \ 37 | sed 's,^package google_protobuf,package descriptor,' google/protobuf/descriptor.pb.go > \ 38 | $(GOPATH)/src/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go && \ 39 | rm -f google/protobuf/descriptor.pb.go 40 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/doc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | /* 33 | A plugin for the Google protocol buffer compiler to generate Go code. 34 | Run it by building this program and putting it in your path with the name 35 | protoc-gen-go 36 | That word 'go' at the end becomes part of the option string set for the 37 | protocol compiler, so once the protocol compiler (protoc) is installed 38 | you can run 39 | protoc --go_out=output_directory input_directory/file.proto 40 | to generate Go bindings for the protocol defined by file.proto. 41 | With that input, the output will be written to 42 | output_directory/file.pb.go 43 | 44 | The generated code is documented in the package comment for 45 | the library. 46 | 47 | See the README and documentation for protocol buffers to learn more: 48 | https://developers.google.com/protocol-buffers/ 49 | 50 | */ 51 | package documentation 52 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/generator/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | include $(GOROOT)/src/Make.inc 33 | 34 | TARG=github.com/golang/protobuf/compiler/generator 35 | GOFILES=\ 36 | generator.go\ 37 | 38 | DEPS=../descriptor ../plugin ../../proto 39 | 40 | include $(GOROOT)/src/Make.pkg 41 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/generator/name_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2013 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package generator 33 | 34 | import ( 35 | "testing" 36 | 37 | "github.com/golang/protobuf/protoc-gen-go/descriptor" 38 | ) 39 | 40 | func TestCamelCase(t *testing.T) { 41 | tests := []struct { 42 | in, want string 43 | }{ 44 | {"one", "One"}, 45 | {"one_two", "OneTwo"}, 46 | {"_my_field_name_2", "XMyFieldName_2"}, 47 | {"Something_Capped", "Something_Capped"}, 48 | {"my_Name", "My_Name"}, 49 | {"OneTwo", "OneTwo"}, 50 | {"_", "X"}, 51 | {"_a_", "XA_"}, 52 | } 53 | for _, tc := range tests { 54 | if got := CamelCase(tc.in); got != tc.want { 55 | t.Errorf("CamelCase(%q) = %q, want %q", tc.in, got, tc.want) 56 | } 57 | } 58 | } 59 | 60 | func TestGoPackageOption(t *testing.T) { 61 | tests := []struct { 62 | in string 63 | impPath, pkg string 64 | ok bool 65 | }{ 66 | {"", "", "", false}, 67 | {"foo", "", "foo", true}, 68 | {"github.com/golang/bar", "github.com/golang/bar", "bar", true}, 69 | {"github.com/golang/bar;baz", "github.com/golang/bar", "baz", true}, 70 | } 71 | for _, tc := range tests { 72 | d := &FileDescriptor{ 73 | FileDescriptorProto: &descriptor.FileDescriptorProto{ 74 | Options: &descriptor.FileOptions{ 75 | GoPackage: &tc.in, 76 | }, 77 | }, 78 | } 79 | impPath, pkg, ok := d.goPackageOption() 80 | if impPath != tc.impPath || pkg != tc.pkg || ok != tc.ok { 81 | t.Errorf("go_package = %q => (%q, %q, %t), want (%q, %q, %t)", tc.in, 82 | impPath, pkg, ok, tc.impPath, tc.pkg, tc.ok) 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package main 33 | 34 | import _ "github.com/golang/protobuf/protoc-gen-go/grpc" 35 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/main.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // protoc-gen-go is a plugin for the Google protocol buffer compiler to generate 33 | // Go code. Run it by building this program and putting it in your path with 34 | // the name 35 | // protoc-gen-go 36 | // That word 'go' at the end becomes part of the option string set for the 37 | // protocol compiler, so once the protocol compiler (protoc) is installed 38 | // you can run 39 | // protoc --go_out=output_directory input_directory/file.proto 40 | // to generate Go bindings for the protocol defined by file.proto. 41 | // With that input, the output will be written to 42 | // output_directory/file.pb.go 43 | // 44 | // The generated code is documented in the package comment for 45 | // the library. 46 | // 47 | // See the README and documentation for protocol buffers to learn more: 48 | // https://developers.google.com/protocol-buffers/ 49 | package main 50 | 51 | import ( 52 | "io/ioutil" 53 | "os" 54 | 55 | "github.com/golang/protobuf/proto" 56 | "github.com/golang/protobuf/protoc-gen-go/generator" 57 | ) 58 | 59 | func main() { 60 | // Begin by allocating a generator. The request and response structures are stored there 61 | // so we can do error handling easily - the response structure contains the field to 62 | // report failure. 63 | g := generator.New() 64 | 65 | data, err := ioutil.ReadAll(os.Stdin) 66 | if err != nil { 67 | g.Error(err, "reading input") 68 | } 69 | 70 | if err := proto.Unmarshal(data, g.Request); err != nil { 71 | g.Error(err, "parsing input proto") 72 | } 73 | 74 | if len(g.Request.FileToGenerate) == 0 { 75 | g.Fail("no files to generate") 76 | } 77 | 78 | g.CommandLineParameters(g.Request.GetParameter()) 79 | 80 | // Create a wrapped version of the Descriptors and EnumDescriptors that 81 | // point to the file that defines them. 82 | g.WrapTypes() 83 | 84 | g.SetPackageNames() 85 | g.BuildTypeNameMap() 86 | 87 | g.GenerateAllFiles() 88 | 89 | // Send back the results. 90 | data, err = proto.Marshal(g.Response) 91 | if err != nil { 92 | g.Error(err, "failed to marshal output proto") 93 | } 94 | _, err = os.Stdout.Write(data) 95 | if err != nil { 96 | g.Error(err, "failed to write output proto") 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/plugin/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Not stored here, but plugin.proto is in https://github.com/google/protobuf/ 33 | # at src/google/protobuf/compiler/plugin.proto 34 | # Also we need to fix an import. 35 | regenerate: 36 | echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION 37 | protoc --go_out=Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor:. \ 38 | -I$(HOME)/src/protobuf/src $(HOME)/src/protobuf/src/google/protobuf/compiler/plugin.proto && \ 39 | mv google/protobuf/compiler/plugin.pb.go $(GOPATH)/src/github.com/golang/protobuf/protoc-gen-go/plugin 40 | 41 | restore: 42 | cp plugin.pb.golden plugin.pb.go 43 | 44 | preserve: 45 | cp plugin.pb.go plugin.pb.golden 46 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.golden: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: google/protobuf/compiler/plugin.proto 3 | // DO NOT EDIT! 4 | 5 | package google_protobuf_compiler 6 | 7 | import proto "github.com/golang/protobuf/proto" 8 | import "math" 9 | import google_protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" 10 | 11 | // Reference proto and math imports to suppress error if they are not otherwise used. 12 | var _ = proto.GetString 13 | var _ = math.Inf 14 | 15 | type CodeGeneratorRequest struct { 16 | FileToGenerate []string `protobuf:"bytes,1,rep,name=file_to_generate" json:"file_to_generate,omitempty"` 17 | Parameter *string `protobuf:"bytes,2,opt,name=parameter" json:"parameter,omitempty"` 18 | ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file" json:"proto_file,omitempty"` 19 | XXX_unrecognized []byte `json:"-"` 20 | } 21 | 22 | func (this *CodeGeneratorRequest) Reset() { *this = CodeGeneratorRequest{} } 23 | func (this *CodeGeneratorRequest) String() string { return proto.CompactTextString(this) } 24 | func (*CodeGeneratorRequest) ProtoMessage() {} 25 | 26 | func (this *CodeGeneratorRequest) GetParameter() string { 27 | if this != nil && this.Parameter != nil { 28 | return *this.Parameter 29 | } 30 | return "" 31 | } 32 | 33 | type CodeGeneratorResponse struct { 34 | Error *string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` 35 | File []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"` 36 | XXX_unrecognized []byte `json:"-"` 37 | } 38 | 39 | func (this *CodeGeneratorResponse) Reset() { *this = CodeGeneratorResponse{} } 40 | func (this *CodeGeneratorResponse) String() string { return proto.CompactTextString(this) } 41 | func (*CodeGeneratorResponse) ProtoMessage() {} 42 | 43 | func (this *CodeGeneratorResponse) GetError() string { 44 | if this != nil && this.Error != nil { 45 | return *this.Error 46 | } 47 | return "" 48 | } 49 | 50 | type CodeGeneratorResponse_File struct { 51 | Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` 52 | InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point" json:"insertion_point,omitempty"` 53 | Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"` 54 | XXX_unrecognized []byte `json:"-"` 55 | } 56 | 57 | func (this *CodeGeneratorResponse_File) Reset() { *this = CodeGeneratorResponse_File{} } 58 | func (this *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(this) } 59 | func (*CodeGeneratorResponse_File) ProtoMessage() {} 60 | 61 | func (this *CodeGeneratorResponse_File) GetName() string { 62 | if this != nil && this.Name != nil { 63 | return *this.Name 64 | } 65 | return "" 66 | } 67 | 68 | func (this *CodeGeneratorResponse_File) GetInsertionPoint() string { 69 | if this != nil && this.InsertionPoint != nil { 70 | return *this.InsertionPoint 71 | } 72 | return "" 73 | } 74 | 75 | func (this *CodeGeneratorResponse_File) GetContent() string { 76 | if this != nil && this.Content != nil { 77 | return *this.Content 78 | } 79 | return "" 80 | } 81 | 82 | func init() { 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | all: 33 | @echo run make test 34 | 35 | include ../../Make.protobuf 36 | 37 | test: golden testbuild 38 | 39 | #test: golden testbuild extension_test 40 | # ./extension_test 41 | # @echo PASS 42 | 43 | my_test/test.pb.go: my_test/test.proto 44 | protoc --go_out=Mmulti/multi1.proto=github.com/golang/protobuf/protoc-gen-go/testdata/multi:. $< 45 | 46 | golden: 47 | make -B my_test/test.pb.go 48 | sed -i '/return.*fileDescriptor/d' my_test/test.pb.go 49 | sed -i '/^var fileDescriptor/,/^}/d' my_test/test.pb.go 50 | sed -i '/proto.RegisterFile.*fileDescriptor/d' my_test/test.pb.go 51 | gofmt -w my_test/test.pb.go 52 | diff -w my_test/test.pb.go my_test/test.pb.go.golden 53 | 54 | nuke: clean 55 | 56 | testbuild: regenerate 57 | go test 58 | 59 | regenerate: 60 | # Invoke protoc once to generate three independent .pb.go files in the same package. 61 | protoc --go_out=. multi/multi{1,2,3}.proto 62 | 63 | #extension_test: extension_test.$O 64 | # $(LD) -L. -o $@ $< 65 | 66 | #multi.a: multi3.pb.$O multi2.pb.$O multi1.pb.$O 67 | # rm -f multi.a 68 | # $(QUOTED_GOBIN)/gopack grc $@ $< 69 | 70 | #test.pb.go: imp.pb.go 71 | #multi1.pb.go: multi2.pb.go multi3.pb.go 72 | #main.$O: imp.pb.$O test.pb.$O multi.a 73 | #extension_test.$O: extension_base.pb.$O extension_extra.pb.$O extension_user.pb.$O 74 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/extension_base.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package extension_base; 35 | 36 | message BaseMessage { 37 | optional int32 height = 1; 38 | extensions 4 to 9; 39 | extensions 16 to max; 40 | } 41 | 42 | // Another message that may be extended, using message_set_wire_format. 43 | message OldStyleMessage { 44 | option message_set_wire_format = true; 45 | extensions 100 to max; 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/extension_extra.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2011 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package extension_extra; 35 | 36 | message ExtraMessage { 37 | optional int32 width = 1; 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/extension_user.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | import "extension_base.proto"; 35 | import "extension_extra.proto"; 36 | 37 | package extension_user; 38 | 39 | message UserMessage { 40 | optional string name = 1; 41 | optional string rank = 2; 42 | } 43 | 44 | // Extend with a message 45 | extend extension_base.BaseMessage { 46 | optional UserMessage user_message = 5; 47 | } 48 | 49 | // Extend with a foreign message 50 | extend extension_base.BaseMessage { 51 | optional extension_extra.ExtraMessage extra_message = 9; 52 | } 53 | 54 | // Extend with some primitive types 55 | extend extension_base.BaseMessage { 56 | optional int32 width = 6; 57 | optional int64 area = 7; 58 | } 59 | 60 | // Extend inside the scope of another type 61 | message LoudMessage { 62 | extend extension_base.BaseMessage { 63 | optional uint32 volume = 8; 64 | } 65 | extensions 100 to max; 66 | } 67 | 68 | // Extend inside the scope of another type, using a message. 69 | message LoginMessage { 70 | extend extension_base.BaseMessage { 71 | optional UserMessage user_message = 16; 72 | } 73 | } 74 | 75 | // Extend with a repeated field 76 | extend extension_base.BaseMessage { 77 | repeated Detail detail = 17; 78 | } 79 | 80 | message Detail { 81 | optional string color = 1; 82 | } 83 | 84 | // An extension of an extension 85 | message Announcement { 86 | optional string words = 1; 87 | extend LoudMessage { 88 | optional Announcement loud_ext = 100; 89 | } 90 | } 91 | 92 | // Something that can be put in a message set. 93 | message OldStyleParcel { 94 | extend extension_base.OldStyleMessage { 95 | optional OldStyleParcel message_set_extension = 2001; 96 | } 97 | 98 | required string name = 1; 99 | optional int32 height = 2; 100 | } 101 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/grpc.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto3"; 33 | 34 | package grpc.testing; 35 | 36 | message SimpleRequest { 37 | } 38 | 39 | message SimpleResponse { 40 | } 41 | 42 | message StreamMsg { 43 | } 44 | 45 | message StreamMsg2 { 46 | } 47 | 48 | service Test { 49 | rpc UnaryCall(SimpleRequest) returns (SimpleResponse); 50 | 51 | // This RPC streams from the server only. 52 | rpc Downstream(SimpleRequest) returns (stream StreamMsg); 53 | 54 | // This RPC streams from the client. 55 | rpc Upstream(stream StreamMsg) returns (SimpleResponse); 56 | 57 | // This one streams in both directions. 58 | rpc Bidi(stream StreamMsg) returns (stream StreamMsg2); 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/imp.pb.go.golden: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: imp.proto 3 | // DO NOT EDIT! 4 | 5 | package imp 6 | 7 | import proto "github.com/golang/protobuf/proto" 8 | import "math" 9 | import "os" 10 | import imp1 "imp2.pb" 11 | 12 | // Reference proto & math imports to suppress error if they are not otherwise used. 13 | var _ = proto.GetString 14 | var _ = math.Inf 15 | 16 | // Types from public import imp2.proto 17 | type PubliclyImportedMessage imp1.PubliclyImportedMessage 18 | 19 | func (this *PubliclyImportedMessage) Reset() { (*imp1.PubliclyImportedMessage)(this).Reset() } 20 | func (this *PubliclyImportedMessage) String() string { 21 | return (*imp1.PubliclyImportedMessage)(this).String() 22 | } 23 | 24 | // PubliclyImportedMessage from public import imp.proto 25 | 26 | type ImportedMessage_Owner int32 27 | 28 | const ( 29 | ImportedMessage_DAVE ImportedMessage_Owner = 1 30 | ImportedMessage_MIKE ImportedMessage_Owner = 2 31 | ) 32 | 33 | var ImportedMessage_Owner_name = map[int32]string{ 34 | 1: "DAVE", 35 | 2: "MIKE", 36 | } 37 | var ImportedMessage_Owner_value = map[string]int32{ 38 | "DAVE": 1, 39 | "MIKE": 2, 40 | } 41 | 42 | // NewImportedMessage_Owner is deprecated. Use x.Enum() instead. 43 | func NewImportedMessage_Owner(x ImportedMessage_Owner) *ImportedMessage_Owner { 44 | e := ImportedMessage_Owner(x) 45 | return &e 46 | } 47 | func (x ImportedMessage_Owner) Enum() *ImportedMessage_Owner { 48 | p := new(ImportedMessage_Owner) 49 | *p = x 50 | return p 51 | } 52 | func (x ImportedMessage_Owner) String() string { 53 | return proto.EnumName(ImportedMessage_Owner_name, int32(x)) 54 | } 55 | 56 | type ImportedMessage struct { 57 | Field *int64 `protobuf:"varint,1,req,name=field" json:"field,omitempty"` 58 | XXX_extensions map[int32][]byte `json:",omitempty"` 59 | XXX_unrecognized []byte `json:",omitempty"` 60 | } 61 | 62 | func (this *ImportedMessage) Reset() { *this = ImportedMessage{} } 63 | func (this *ImportedMessage) String() string { return proto.CompactTextString(this) } 64 | 65 | var extRange_ImportedMessage = []proto.ExtensionRange{ 66 | proto.ExtensionRange{90, 100}, 67 | } 68 | 69 | func (*ImportedMessage) ExtensionRangeArray() []proto.ExtensionRange { 70 | return extRange_ImportedMessage 71 | } 72 | func (this *ImportedMessage) ExtensionMap() map[int32][]byte { 73 | if this.XXX_extensions == nil { 74 | this.XXX_extensions = make(map[int32][]byte) 75 | } 76 | return this.XXX_extensions 77 | } 78 | 79 | type ImportedExtendable struct { 80 | XXX_extensions map[int32][]byte `json:",omitempty"` 81 | XXX_unrecognized []byte `json:",omitempty"` 82 | } 83 | 84 | func (this *ImportedExtendable) Reset() { *this = ImportedExtendable{} } 85 | func (this *ImportedExtendable) String() string { return proto.CompactTextString(this) } 86 | 87 | func (this *ImportedExtendable) Marshal() ([]byte, error) { 88 | return proto.MarshalMessageSet(this.ExtensionMap()) 89 | } 90 | func (this *ImportedExtendable) Unmarshal(buf []byte) error { 91 | return proto.UnmarshalMessageSet(buf, this.ExtensionMap()) 92 | } 93 | // ensure ImportedExtendable satisfies proto.Marshaler and proto.Unmarshaler 94 | var _ proto.Marshaler = (*ImportedExtendable)(nil) 95 | var _ proto.Unmarshaler = (*ImportedExtendable)(nil) 96 | 97 | var extRange_ImportedExtendable = []proto.ExtensionRange{ 98 | proto.ExtensionRange{100, 536870911}, 99 | } 100 | 101 | func (*ImportedExtendable) ExtensionRangeArray() []proto.ExtensionRange { 102 | return extRange_ImportedExtendable 103 | } 104 | func (this *ImportedExtendable) ExtensionMap() map[int32][]byte { 105 | if this.XXX_extensions == nil { 106 | this.XXX_extensions = make(map[int32][]byte) 107 | } 108 | return this.XXX_extensions 109 | } 110 | 111 | func init() { 112 | proto.RegisterEnum("imp.ImportedMessage_Owner", ImportedMessage_Owner_name, ImportedMessage_Owner_value) 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/imp.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package imp; 35 | 36 | import "imp2.proto"; 37 | import "imp3.proto"; 38 | 39 | message ImportedMessage { 40 | required int64 field = 1; 41 | 42 | // The forwarded getters for these fields are fiddly to get right. 43 | optional ImportedMessage2 local_msg = 2; 44 | optional ForeignImportedMessage foreign_msg = 3; // in imp3.proto 45 | optional Owner enum_field = 4; 46 | oneof union { 47 | int32 state = 9; 48 | } 49 | 50 | repeated string name = 5; 51 | repeated Owner boss = 6; 52 | repeated ImportedMessage2 memo = 7; 53 | 54 | map msg_map = 8; 55 | 56 | enum Owner { 57 | DAVE = 1; 58 | MIKE = 2; 59 | } 60 | 61 | extensions 90 to 100; 62 | } 63 | 64 | message ImportedMessage2 { 65 | } 66 | 67 | message ImportedExtendable { 68 | option message_set_wire_format = true; 69 | extensions 100 to max; 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/imp2.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2011 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package imp; 35 | 36 | message PubliclyImportedMessage { 37 | optional int64 field = 1; 38 | } 39 | 40 | enum PubliclyImportedEnum { 41 | GLASSES = 1; 42 | HAIR = 2; 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/imp3.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package imp; 35 | 36 | message ForeignImportedMessage { 37 | optional string tuber = 1; 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/main_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // A simple binary to link together the protocol buffers in this test. 33 | 34 | package testdata 35 | 36 | import ( 37 | "testing" 38 | 39 | mytestpb "./my_test" 40 | multipb "github.com/golang/protobuf/protoc-gen-go/testdata/multi" 41 | ) 42 | 43 | func TestLink(t *testing.T) { 44 | _ = &multipb.Multi1{} 45 | _ = &mytestpb.Request{} 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/multi/multi1.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | import "multi/multi2.proto"; 35 | import "multi/multi3.proto"; 36 | 37 | package multitest; 38 | 39 | message Multi1 { 40 | required Multi2 multi2 = 1; 41 | optional Multi2.Color color = 2; 42 | optional Multi3.HatType hat_type = 3; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/multi/multi2.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package multitest; 35 | 36 | message Multi2 { 37 | required int32 required_value = 1; 38 | 39 | enum Color { 40 | BLUE = 1; 41 | GREEN = 2; 42 | RED = 3; 43 | }; 44 | optional Color color = 2; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/multi/multi3.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package multitest; 35 | 36 | message Multi3 { 37 | enum HatType { 38 | FEDORA = 1; 39 | FEZ = 2; 40 | }; 41 | optional HatType hat_type = 1; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/my_test/test.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | // This package holds interesting messages. 35 | package my.test; // dotted package name 36 | 37 | //import "imp.proto"; 38 | import "multi/multi1.proto"; // unused import 39 | 40 | enum HatType { 41 | // deliberately skipping 0 42 | FEDORA = 1; 43 | FEZ = 2; 44 | } 45 | 46 | // This enum represents days of the week. 47 | enum Days { 48 | option allow_alias = true; 49 | 50 | MONDAY = 1; 51 | TUESDAY = 2; 52 | LUNDI = 1; // same value as MONDAY 53 | } 54 | 55 | // This is a message that might be sent somewhere. 56 | message Request { 57 | enum Color { 58 | RED = 0; 59 | GREEN = 1; 60 | BLUE = 2; 61 | } 62 | repeated int64 key = 1; 63 | // optional imp.ImportedMessage imported_message = 2; 64 | optional Color hue = 3; // no default 65 | optional HatType hat = 4 [default=FEDORA]; 66 | // optional imp.ImportedMessage.Owner owner = 6; 67 | optional float deadline = 7 [default=inf]; 68 | optional group SomeGroup = 8 { 69 | optional int32 group_field = 9; 70 | } 71 | 72 | // These foreign types are in imp2.proto, 73 | // which is publicly imported by imp.proto. 74 | // optional imp.PubliclyImportedMessage pub = 10; 75 | // optional imp.PubliclyImportedEnum pub_enum = 13 [default=HAIR]; 76 | 77 | 78 | // This is a map field. It will generate map[int32]string. 79 | map name_mapping = 14; 80 | // This is a map field whose value type is a message. 81 | map msg_mapping = 15; 82 | 83 | optional int32 reset = 12; 84 | // This field should not conflict with any getters. 85 | optional string get_key = 16; 86 | } 87 | 88 | message Reply { 89 | message Entry { 90 | required int64 key_that_needs_1234camel_CasIng = 1; 91 | optional int64 value = 2 [default=7]; 92 | optional int64 _my_field_name_2 = 3; 93 | enum Game { 94 | FOOTBALL = 1; 95 | TENNIS = 2; 96 | } 97 | } 98 | repeated Entry found = 1; 99 | repeated int32 compact_keys = 2 [packed=true]; 100 | extensions 100 to max; 101 | } 102 | 103 | message OtherBase { 104 | optional string name = 1; 105 | extensions 100 to max; 106 | } 107 | 108 | message ReplyExtensions { 109 | extend Reply { 110 | optional double time = 101; 111 | optional ReplyExtensions carrot = 105; 112 | } 113 | extend OtherBase { 114 | optional ReplyExtensions donut = 101; 115 | } 116 | } 117 | 118 | message OtherReplyExtensions { 119 | optional int32 key = 1; 120 | } 121 | 122 | // top-level extension 123 | extend Reply { 124 | optional string tag = 103; 125 | optional OtherReplyExtensions donut = 106; 126 | // optional imp.ImportedMessage elephant = 107; // extend with message from another file. 127 | } 128 | 129 | message OldReply { 130 | // Extensions will be encoded in MessageSet wire format. 131 | option message_set_wire_format = true; 132 | extensions 100 to max; 133 | } 134 | 135 | message Communique { 136 | optional bool make_me_cry = 1; 137 | 138 | // This is a oneof, called "union". 139 | oneof union { 140 | int32 number = 5; 141 | string name = 6; 142 | bytes data = 7; 143 | double temp_c = 8; 144 | float height = 9; 145 | Days today = 10; 146 | bool maybe = 11; 147 | sint32 delta = 12; // name will conflict with Delta below 148 | Reply msg = 13; 149 | group SomeGroup = 14 { 150 | optional string member = 15; 151 | } 152 | } 153 | 154 | message Delta {} 155 | } 156 | 157 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/protoc-gen-go/testdata/proto3.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto3"; 33 | 34 | package proto3; 35 | 36 | message Request { 37 | enum Flavour { 38 | SWEET = 0; 39 | SOUR = 1; 40 | UMAMI = 2; 41 | GOPHERLICIOUS = 3; 42 | } 43 | string name = 1; 44 | repeated int64 key = 2; 45 | Flavour taste = 3; 46 | Book book = 4; 47 | repeated int64 unpacked = 5 [packed=false]; 48 | } 49 | 50 | message Book { 51 | string title = 1; 52 | bytes raw_data = 2; 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/any.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | // This file implements functions to marshal proto.Message to/from 35 | // google.protobuf.Any message. 36 | 37 | import ( 38 | "fmt" 39 | "reflect" 40 | "strings" 41 | 42 | "github.com/golang/protobuf/proto" 43 | "github.com/golang/protobuf/ptypes/any" 44 | ) 45 | 46 | const googleApis = "type.googleapis.com/" 47 | 48 | // AnyMessageName returns the name of the message contained in a google.protobuf.Any message. 49 | // 50 | // Note that regular type assertions should be done using the Is 51 | // function. AnyMessageName is provided for less common use cases like filtering a 52 | // sequence of Any messages based on a set of allowed message type names. 53 | func AnyMessageName(any *any.Any) (string, error) { 54 | slash := strings.LastIndex(any.TypeUrl, "/") 55 | if slash < 0 { 56 | return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl) 57 | } 58 | return any.TypeUrl[slash+1:], nil 59 | } 60 | 61 | // MarshalAny takes the protocol buffer and encodes it into google.protobuf.Any. 62 | func MarshalAny(pb proto.Message) (*any.Any, error) { 63 | value, err := proto.Marshal(pb) 64 | if err != nil { 65 | return nil, err 66 | } 67 | return &any.Any{TypeUrl: googleApis + proto.MessageName(pb), Value: value}, nil 68 | } 69 | 70 | // DynamicAny is a value that can be passed to UnmarshalAny to automatically 71 | // allocate a proto.Message for the type specified in a google.protobuf.Any 72 | // message. The allocated message is stored in the embedded proto.Message. 73 | // 74 | // Example: 75 | // 76 | // var x ptypes.DynamicAny 77 | // if err := ptypes.UnmarshalAny(a, &x); err != nil { ... } 78 | // fmt.Printf("unmarshaled message: %v", x.Message) 79 | type DynamicAny struct { 80 | proto.Message 81 | } 82 | 83 | // Empty returns a new proto.Message of the type specified in a 84 | // google.protobuf.Any message. It returns an error if corresponding message 85 | // type isn't linked in. 86 | func Empty(any *any.Any) (proto.Message, error) { 87 | aname, err := AnyMessageName(any) 88 | if err != nil { 89 | return nil, err 90 | } 91 | 92 | t := proto.MessageType(aname) 93 | if t == nil { 94 | return nil, fmt.Errorf("any: message type %q isn't linked in", aname) 95 | } 96 | return reflect.New(t.Elem()).Interface().(proto.Message), nil 97 | } 98 | 99 | // UnmarshalAny parses the protocol buffer representation in a google.protobuf.Any 100 | // message and places the decoded result in pb. It returns an error if type of 101 | // contents of Any message does not match type of pb message. 102 | // 103 | // pb can be a proto.Message, or a *DynamicAny. 104 | func UnmarshalAny(any *any.Any, pb proto.Message) error { 105 | if d, ok := pb.(*DynamicAny); ok { 106 | if d.Message == nil { 107 | var err error 108 | d.Message, err = Empty(any) 109 | if err != nil { 110 | return err 111 | } 112 | } 113 | return UnmarshalAny(any, d.Message) 114 | } 115 | 116 | aname, err := AnyMessageName(any) 117 | if err != nil { 118 | return err 119 | } 120 | 121 | mname := proto.MessageName(pb) 122 | if aname != mname { 123 | return fmt.Errorf("mismatched message type: got %q want %q", aname, mname) 124 | } 125 | return proto.Unmarshal(any.Value, pb) 126 | } 127 | 128 | // Is returns true if any value contains a given message type. 129 | func Is(any *any.Any, pb proto.Message) bool { 130 | aname, err := AnyMessageName(any) 131 | if err != nil { 132 | return false 133 | } 134 | 135 | return aname == proto.MessageName(pb) 136 | } 137 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/any/any.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/any"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "AnyProto"; 39 | option java_multiple_files = true; 40 | option java_generate_equals_and_hash = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // `Any` contains an arbitrary serialized protocol buffer message along with a 44 | // URL that describes the type of the serialized message. 45 | // 46 | // Protobuf library provides support to pack/unpack Any values in the form 47 | // of utility functions or additional generated methods of the Any type. 48 | // 49 | // Example 1: Pack and unpack a message in C++. 50 | // 51 | // Foo foo = ...; 52 | // Any any; 53 | // any.PackFrom(foo); 54 | // ... 55 | // if (any.UnpackTo(&foo)) { 56 | // ... 57 | // } 58 | // 59 | // Example 2: Pack and unpack a message in Java. 60 | // 61 | // Foo foo = ...; 62 | // Any any = Any.pack(foo); 63 | // ... 64 | // if (any.is(Foo.class)) { 65 | // foo = any.unpack(Foo.class); 66 | // } 67 | // 68 | // Example 3: Pack and unpack a message in Python. 69 | // 70 | // foo = Foo(...) 71 | // any = Any() 72 | // any.Pack(foo) 73 | // ... 74 | // if any.Is(Foo.DESCRIPTOR): 75 | // any.Unpack(foo) 76 | // ... 77 | // 78 | // The pack methods provided by protobuf library will by default use 79 | // 'type.googleapis.com/full.type.name' as the type URL and the unpack 80 | // methods only use the fully qualified type name after the last '/' 81 | // in the type URL, for example "foo.bar.com/x/y.z" will yield type 82 | // name "y.z". 83 | // 84 | // 85 | // JSON 86 | // ==== 87 | // The JSON representation of an `Any` value uses the regular 88 | // representation of the deserialized, embedded message, with an 89 | // additional field `@type` which contains the type URL. Example: 90 | // 91 | // package google.profile; 92 | // message Person { 93 | // string first_name = 1; 94 | // string last_name = 2; 95 | // } 96 | // 97 | // { 98 | // "@type": "type.googleapis.com/google.profile.Person", 99 | // "firstName": , 100 | // "lastName": 101 | // } 102 | // 103 | // If the embedded message type is well-known and has a custom JSON 104 | // representation, that representation will be embedded adding a field 105 | // `value` which holds the custom JSON in addition to the `@type` 106 | // field. Example (for message [google.protobuf.Duration][]): 107 | // 108 | // { 109 | // "@type": "type.googleapis.com/google.protobuf.Duration", 110 | // "value": "1.212s" 111 | // } 112 | // 113 | message Any { 114 | // A URL/resource name whose content describes the type of the 115 | // serialized protocol buffer message. 116 | // 117 | // For URLs which use the scheme `http`, `https`, or no scheme, the 118 | // following restrictions and interpretations apply: 119 | // 120 | // * If no scheme is provided, `https` is assumed. 121 | // * The last segment of the URL's path must represent the fully 122 | // qualified name of the type (as in `path/google.protobuf.Duration`). 123 | // The name should be in a canonical form (e.g., leading "." is 124 | // not accepted). 125 | // * An HTTP GET on the URL must yield a [google.protobuf.Type][] 126 | // value in binary format, or produce an error. 127 | // * Applications are allowed to cache lookup results based on the 128 | // URL, or have them precompiled into a binary to avoid any 129 | // lookup. Therefore, binary compatibility needs to be preserved 130 | // on changes to types. (Use versioned type names to manage 131 | // breaking changes.) 132 | // 133 | // Schemes other than `http`, `https` (or the empty scheme) might be 134 | // used with implementation specific semantics. 135 | // 136 | string type_url = 1; 137 | 138 | // Must be a valid serialized protocol buffer of the above specified type. 139 | bytes value = 2; 140 | } 141 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/any_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | import ( 35 | "testing" 36 | 37 | "github.com/golang/protobuf/proto" 38 | pb "github.com/golang/protobuf/protoc-gen-go/descriptor" 39 | "github.com/golang/protobuf/ptypes/any" 40 | ) 41 | 42 | func TestMarshalUnmarshal(t *testing.T) { 43 | orig := &any.Any{Value: []byte("test")} 44 | 45 | packed, err := MarshalAny(orig) 46 | if err != nil { 47 | t.Errorf("MarshalAny(%+v): got: _, %v exp: _, nil", orig, err) 48 | } 49 | 50 | unpacked := &any.Any{} 51 | err = UnmarshalAny(packed, unpacked) 52 | if err != nil || !proto.Equal(unpacked, orig) { 53 | t.Errorf("got: %v, %+v; want nil, %+v", err, unpacked, orig) 54 | } 55 | } 56 | 57 | func TestIs(t *testing.T) { 58 | a, err := MarshalAny(&pb.FileDescriptorProto{}) 59 | if err != nil { 60 | t.Fatal(err) 61 | } 62 | if Is(a, &pb.DescriptorProto{}) { 63 | t.Error("FileDescriptorProto is not a DescriptorProto, but Is says it is") 64 | } 65 | if !Is(a, &pb.FileDescriptorProto{}) { 66 | t.Error("FileDescriptorProto is indeed a FileDescriptorProto, but Is says it is not") 67 | } 68 | } 69 | 70 | func TestIsDifferentUrlPrefixes(t *testing.T) { 71 | m := &pb.FileDescriptorProto{} 72 | a := &any.Any{TypeUrl: "foo/bar/" + proto.MessageName(m)} 73 | if !Is(a, m) { 74 | t.Errorf("message with type url %q didn't satisfy Is for type %q", a.TypeUrl, proto.MessageName(m)) 75 | } 76 | } 77 | 78 | func TestUnmarshalDynamic(t *testing.T) { 79 | want := &pb.FileDescriptorProto{Name: proto.String("foo")} 80 | a, err := MarshalAny(want) 81 | if err != nil { 82 | t.Fatal(err) 83 | } 84 | var got DynamicAny 85 | if err := UnmarshalAny(a, &got); err != nil { 86 | t.Fatal(err) 87 | } 88 | if !proto.Equal(got.Message, want) { 89 | t.Errorf("invalid result from UnmarshalAny, got %q want %q", got.Message, want) 90 | } 91 | } 92 | 93 | func TestEmpty(t *testing.T) { 94 | want := &pb.FileDescriptorProto{} 95 | a, err := MarshalAny(want) 96 | if err != nil { 97 | t.Fatal(err) 98 | } 99 | got, err := Empty(a) 100 | if err != nil { 101 | t.Fatal(err) 102 | } 103 | if !proto.Equal(got, want) { 104 | t.Errorf("unequal empty message, got %q, want %q", got, want) 105 | } 106 | 107 | // that's a valid type_url for a message which shouldn't be linked into this 108 | // test binary. We want an error. 109 | a.TypeUrl = "type.googleapis.com/google.protobuf.FieldMask" 110 | if _, err := Empty(a); err == nil { 111 | t.Errorf("got no error for an attempt to create a message of type %q, which shouldn't be linked in", a.TypeUrl) 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/doc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | /* 33 | Package ptypes contains code for interacting with well-known types. 34 | */ 35 | package ptypes 36 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/duration.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | // This file implements conversions between google.protobuf.Duration 35 | // and time.Duration. 36 | 37 | import ( 38 | "errors" 39 | "fmt" 40 | "time" 41 | 42 | durpb "github.com/golang/protobuf/ptypes/duration" 43 | ) 44 | 45 | const ( 46 | // Range of a durpb.Duration in seconds, as specified in 47 | // google/protobuf/duration.proto. This is about 10,000 years in seconds. 48 | maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60) 49 | minSeconds = -maxSeconds 50 | ) 51 | 52 | // validateDuration determines whether the durpb.Duration is valid according to the 53 | // definition in google/protobuf/duration.proto. A valid durpb.Duration 54 | // may still be too large to fit into a time.Duration (the range of durpb.Duration 55 | // is about 10,000 years, and the range of time.Duration is about 290). 56 | func validateDuration(d *durpb.Duration) error { 57 | if d == nil { 58 | return errors.New("duration: nil Duration") 59 | } 60 | if d.Seconds < minSeconds || d.Seconds > maxSeconds { 61 | return fmt.Errorf("duration: %v: seconds out of range", d) 62 | } 63 | if d.Nanos <= -1e9 || d.Nanos >= 1e9 { 64 | return fmt.Errorf("duration: %v: nanos out of range", d) 65 | } 66 | // Seconds and Nanos must have the same sign, unless d.Nanos is zero. 67 | if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) { 68 | return fmt.Errorf("duration: %v: seconds and nanos have different signs", d) 69 | } 70 | return nil 71 | } 72 | 73 | // Duration converts a durpb.Duration to a time.Duration. Duration 74 | // returns an error if the durpb.Duration is invalid or is too large to be 75 | // represented in a time.Duration. 76 | func Duration(p *durpb.Duration) (time.Duration, error) { 77 | if err := validateDuration(p); err != nil { 78 | return 0, err 79 | } 80 | d := time.Duration(p.Seconds) * time.Second 81 | if int64(d/time.Second) != p.Seconds { 82 | return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) 83 | } 84 | if p.Nanos != 0 { 85 | d += time.Duration(p.Nanos) 86 | if (d < 0) != (p.Nanos < 0) { 87 | return 0, fmt.Errorf("duration: %v is out of range for time.Duration", p) 88 | } 89 | } 90 | return d, nil 91 | } 92 | 93 | // DurationProto converts a time.Duration to a durpb.Duration. 94 | func DurationProto(d time.Duration) *durpb.Duration { 95 | nanos := d.Nanoseconds() 96 | secs := nanos / 1e9 97 | nanos -= secs * 1e9 98 | return &durpb.Duration{ 99 | Seconds: secs, 100 | Nanos: int32(nanos), 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: github.com/golang/protobuf/ptypes/duration/duration.proto 3 | // DO NOT EDIT! 4 | 5 | /* 6 | Package duration is a generated protocol buffer package. 7 | 8 | It is generated from these files: 9 | github.com/golang/protobuf/ptypes/duration/duration.proto 10 | 11 | It has these top-level messages: 12 | Duration 13 | */ 14 | package duration 15 | 16 | import proto "github.com/golang/protobuf/proto" 17 | import fmt "fmt" 18 | import math "math" 19 | 20 | // Reference imports to suppress errors if they are not otherwise used. 21 | var _ = proto.Marshal 22 | var _ = fmt.Errorf 23 | var _ = math.Inf 24 | 25 | // This is a compile-time assertion to ensure that this generated file 26 | // is compatible with the proto package it is being compiled against. 27 | // A compilation error at this line likely means your copy of the 28 | // proto package needs to be updated. 29 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 30 | 31 | // A Duration represents a signed, fixed-length span of time represented 32 | // as a count of seconds and fractions of seconds at nanosecond 33 | // resolution. It is independent of any calendar and concepts like "day" 34 | // or "month". It is related to Timestamp in that the difference between 35 | // two Timestamp values is a Duration and it can be added or subtracted 36 | // from a Timestamp. Range is approximately +-10,000 years. 37 | // 38 | // Example 1: Compute Duration from two Timestamps in pseudo code. 39 | // 40 | // Timestamp start = ...; 41 | // Timestamp end = ...; 42 | // Duration duration = ...; 43 | // 44 | // duration.seconds = end.seconds - start.seconds; 45 | // duration.nanos = end.nanos - start.nanos; 46 | // 47 | // if (duration.seconds < 0 && duration.nanos > 0) { 48 | // duration.seconds += 1; 49 | // duration.nanos -= 1000000000; 50 | // } else if (durations.seconds > 0 && duration.nanos < 0) { 51 | // duration.seconds -= 1; 52 | // duration.nanos += 1000000000; 53 | // } 54 | // 55 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 56 | // 57 | // Timestamp start = ...; 58 | // Duration duration = ...; 59 | // Timestamp end = ...; 60 | // 61 | // end.seconds = start.seconds + duration.seconds; 62 | // end.nanos = start.nanos + duration.nanos; 63 | // 64 | // if (end.nanos < 0) { 65 | // end.seconds -= 1; 66 | // end.nanos += 1000000000; 67 | // } else if (end.nanos >= 1000000000) { 68 | // end.seconds += 1; 69 | // end.nanos -= 1000000000; 70 | // } 71 | // 72 | // 73 | type Duration struct { 74 | // Signed seconds of the span of time. Must be from -315,576,000,000 75 | // to +315,576,000,000 inclusive. 76 | Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` 77 | // Signed fractions of a second at nanosecond resolution of the span 78 | // of time. Durations less than one second are represented with a 0 79 | // `seconds` field and a positive or negative `nanos` field. For durations 80 | // of one second or more, a non-zero value for the `nanos` field must be 81 | // of the same sign as the `seconds` field. Must be from -999,999,999 82 | // to +999,999,999 inclusive. 83 | Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` 84 | } 85 | 86 | func (m *Duration) Reset() { *m = Duration{} } 87 | func (m *Duration) String() string { return proto.CompactTextString(m) } 88 | func (*Duration) ProtoMessage() {} 89 | func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 90 | func (*Duration) XXX_WellKnownType() string { return "Duration" } 91 | 92 | func init() { 93 | proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") 94 | } 95 | 96 | func init() { 97 | proto.RegisterFile("github.com/golang/protobuf/ptypes/duration/duration.proto", fileDescriptor0) 98 | } 99 | 100 | var fileDescriptor0 = []byte{ 101 | // 189 bytes of a gzipped FileDescriptorProto 102 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, 103 | 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, 104 | 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x29, 105 | 0x2d, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0x83, 0x33, 0xf4, 0xc0, 0x2a, 0x84, 0xf8, 0xd3, 0xf3, 0xf3, 106 | 0xd3, 0x73, 0x52, 0xf5, 0x60, 0xea, 0x95, 0xac, 0xb8, 0x38, 0x5c, 0xa0, 0x4a, 0x84, 0x24, 0xb8, 107 | 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0x60, 108 | 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xd6, 109 | 0x20, 0x08, 0xc7, 0xa9, 0x86, 0x4b, 0x38, 0x39, 0x3f, 0x57, 0x0f, 0xcd, 0x48, 0x27, 0x5e, 0x98, 110 | 0x81, 0x01, 0x20, 0x91, 0x00, 0xc6, 0x28, 0x2d, 0xe2, 0xdd, 0xbb, 0x80, 0x91, 0x71, 0x11, 0x13, 111 | 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xb9, 0x01, 0x50, 0xa5, 0x7a, 0xe1, 0xa9, 112 | 0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x2d, 0x49, 0x6c, 0x60, 0x33, 0x8c, 0x01, 113 | 0x01, 0x00, 0x00, 0xff, 0xff, 0x62, 0xfb, 0xb1, 0x51, 0x0e, 0x01, 0x00, 0x00, 114 | } 115 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/duration/duration.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/duration"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "DurationProto"; 39 | option java_multiple_files = true; 40 | option java_generate_equals_and_hash = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Duration represents a signed, fixed-length span of time represented 44 | // as a count of seconds and fractions of seconds at nanosecond 45 | // resolution. It is independent of any calendar and concepts like "day" 46 | // or "month". It is related to Timestamp in that the difference between 47 | // two Timestamp values is a Duration and it can be added or subtracted 48 | // from a Timestamp. Range is approximately +-10,000 years. 49 | // 50 | // Example 1: Compute Duration from two Timestamps in pseudo code. 51 | // 52 | // Timestamp start = ...; 53 | // Timestamp end = ...; 54 | // Duration duration = ...; 55 | // 56 | // duration.seconds = end.seconds - start.seconds; 57 | // duration.nanos = end.nanos - start.nanos; 58 | // 59 | // if (duration.seconds < 0 && duration.nanos > 0) { 60 | // duration.seconds += 1; 61 | // duration.nanos -= 1000000000; 62 | // } else if (durations.seconds > 0 && duration.nanos < 0) { 63 | // duration.seconds -= 1; 64 | // duration.nanos += 1000000000; 65 | // } 66 | // 67 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 68 | // 69 | // Timestamp start = ...; 70 | // Duration duration = ...; 71 | // Timestamp end = ...; 72 | // 73 | // end.seconds = start.seconds + duration.seconds; 74 | // end.nanos = start.nanos + duration.nanos; 75 | // 76 | // if (end.nanos < 0) { 77 | // end.seconds -= 1; 78 | // end.nanos += 1000000000; 79 | // } else if (end.nanos >= 1000000000) { 80 | // end.seconds += 1; 81 | // end.nanos -= 1000000000; 82 | // } 83 | // 84 | // 85 | message Duration { 86 | 87 | // Signed seconds of the span of time. Must be from -315,576,000,000 88 | // to +315,576,000,000 inclusive. 89 | int64 seconds = 1; 90 | 91 | // Signed fractions of a second at nanosecond resolution of the span 92 | // of time. Durations less than one second are represented with a 0 93 | // `seconds` field and a positive or negative `nanos` field. For durations 94 | // of one second or more, a non-zero value for the `nanos` field must be 95 | // of the same sign as the `seconds` field. Must be from -999,999,999 96 | // to +999,999,999 inclusive. 97 | int32 nanos = 2; 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/duration_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | import ( 35 | "math" 36 | "testing" 37 | "time" 38 | 39 | "github.com/golang/protobuf/proto" 40 | durpb "github.com/golang/protobuf/ptypes/duration" 41 | ) 42 | 43 | const ( 44 | minGoSeconds = math.MinInt64 / int64(1e9) 45 | maxGoSeconds = math.MaxInt64 / int64(1e9) 46 | ) 47 | 48 | var durationTests = []struct { 49 | proto *durpb.Duration 50 | isValid bool 51 | inRange bool 52 | dur time.Duration 53 | }{ 54 | // The zero duration. 55 | {&durpb.Duration{0, 0}, true, true, 0}, 56 | // Some ordinary non-zero durations. 57 | {&durpb.Duration{100, 0}, true, true, 100 * time.Second}, 58 | {&durpb.Duration{-100, 0}, true, true, -100 * time.Second}, 59 | {&durpb.Duration{100, 987}, true, true, 100*time.Second + 987}, 60 | {&durpb.Duration{-100, -987}, true, true, -(100*time.Second + 987)}, 61 | // The largest duration representable in Go. 62 | {&durpb.Duration{maxGoSeconds, int32(math.MaxInt64 - 1e9*maxGoSeconds)}, true, true, math.MaxInt64}, 63 | // The smallest duration representable in Go. 64 | {&durpb.Duration{minGoSeconds, int32(math.MinInt64 - 1e9*minGoSeconds)}, true, true, math.MinInt64}, 65 | {nil, false, false, 0}, 66 | {&durpb.Duration{-100, 987}, false, false, 0}, 67 | {&durpb.Duration{100, -987}, false, false, 0}, 68 | {&durpb.Duration{math.MinInt64, 0}, false, false, 0}, 69 | {&durpb.Duration{math.MaxInt64, 0}, false, false, 0}, 70 | // The largest valid duration. 71 | {&durpb.Duration{maxSeconds, 1e9 - 1}, true, false, 0}, 72 | // The smallest valid duration. 73 | {&durpb.Duration{minSeconds, -(1e9 - 1)}, true, false, 0}, 74 | // The smallest invalid duration above the valid range. 75 | {&durpb.Duration{maxSeconds + 1, 0}, false, false, 0}, 76 | // The largest invalid duration below the valid range. 77 | {&durpb.Duration{minSeconds - 1, -(1e9 - 1)}, false, false, 0}, 78 | // One nanosecond past the largest duration representable in Go. 79 | {&durpb.Duration{maxGoSeconds, int32(math.MaxInt64-1e9*maxGoSeconds) + 1}, true, false, 0}, 80 | // One nanosecond past the smallest duration representable in Go. 81 | {&durpb.Duration{minGoSeconds, int32(math.MinInt64-1e9*minGoSeconds) - 1}, true, false, 0}, 82 | // One second past the largest duration representable in Go. 83 | {&durpb.Duration{maxGoSeconds + 1, int32(math.MaxInt64 - 1e9*maxGoSeconds)}, true, false, 0}, 84 | // One second past the smallest duration representable in Go. 85 | {&durpb.Duration{minGoSeconds - 1, int32(math.MinInt64 - 1e9*minGoSeconds)}, true, false, 0}, 86 | } 87 | 88 | func TestValidateDuration(t *testing.T) { 89 | for _, test := range durationTests { 90 | err := validateDuration(test.proto) 91 | gotValid := (err == nil) 92 | if gotValid != test.isValid { 93 | t.Errorf("validateDuration(%v) = %t, want %t", test.proto, gotValid, test.isValid) 94 | } 95 | } 96 | } 97 | 98 | func TestDuration(t *testing.T) { 99 | for _, test := range durationTests { 100 | got, err := Duration(test.proto) 101 | gotOK := (err == nil) 102 | wantOK := test.isValid && test.inRange 103 | if gotOK != wantOK { 104 | t.Errorf("Duration(%v) ok = %t, want %t", test.proto, gotOK, wantOK) 105 | } 106 | if err == nil && got != test.dur { 107 | t.Errorf("Duration(%v) = %v, want %v", test.proto, got, test.dur) 108 | } 109 | } 110 | } 111 | 112 | func TestDurationProto(t *testing.T) { 113 | for _, test := range durationTests { 114 | if test.isValid && test.inRange { 115 | got := DurationProto(test.dur) 116 | if !proto.Equal(got, test.proto) { 117 | t.Errorf("DurationProto(%v) = %v, want %v", test.dur, got, test.proto) 118 | } 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: github.com/golang/protobuf/ptypes/empty/empty.proto 3 | // DO NOT EDIT! 4 | 5 | /* 6 | Package empty is a generated protocol buffer package. 7 | 8 | It is generated from these files: 9 | github.com/golang/protobuf/ptypes/empty/empty.proto 10 | 11 | It has these top-level messages: 12 | Empty 13 | */ 14 | package empty 15 | 16 | import proto "github.com/golang/protobuf/proto" 17 | import fmt "fmt" 18 | import math "math" 19 | 20 | // Reference imports to suppress errors if they are not otherwise used. 21 | var _ = proto.Marshal 22 | var _ = fmt.Errorf 23 | var _ = math.Inf 24 | 25 | // This is a compile-time assertion to ensure that this generated file 26 | // is compatible with the proto package it is being compiled against. 27 | // A compilation error at this line likely means your copy of the 28 | // proto package needs to be updated. 29 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 30 | 31 | // A generic empty message that you can re-use to avoid defining duplicated 32 | // empty messages in your APIs. A typical example is to use it as the request 33 | // or the response type of an API method. For instance: 34 | // 35 | // service Foo { 36 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 37 | // } 38 | // 39 | // The JSON representation for `Empty` is empty JSON object `{}`. 40 | type Empty struct { 41 | } 42 | 43 | func (m *Empty) Reset() { *m = Empty{} } 44 | func (m *Empty) String() string { return proto.CompactTextString(m) } 45 | func (*Empty) ProtoMessage() {} 46 | func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 47 | func (*Empty) XXX_WellKnownType() string { return "Empty" } 48 | 49 | func init() { 50 | proto.RegisterType((*Empty)(nil), "google.protobuf.Empty") 51 | } 52 | 53 | func init() { 54 | proto.RegisterFile("github.com/golang/protobuf/ptypes/empty/empty.proto", fileDescriptor0) 55 | } 56 | 57 | var fileDescriptor0 = []byte{ 58 | // 150 bytes of a gzipped FileDescriptorProto 59 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 60 | 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, 61 | 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xcd, 62 | 0x2d, 0x28, 0xa9, 0x84, 0x90, 0x7a, 0x60, 0x39, 0x21, 0xfe, 0xf4, 0xfc, 0xfc, 0xf4, 0x9c, 0x54, 63 | 0x3d, 0x98, 0x4a, 0x25, 0x76, 0x2e, 0x56, 0x57, 0x90, 0xbc, 0x53, 0x25, 0x97, 0x70, 0x72, 0x7e, 64 | 0xae, 0x1e, 0x9a, 0xbc, 0x13, 0x17, 0x58, 0x36, 0x00, 0xc4, 0x0d, 0x60, 0x8c, 0x52, 0x27, 0xd2, 65 | 0xce, 0x05, 0x8c, 0x8c, 0x3f, 0x18, 0x19, 0x17, 0x31, 0x31, 0xbb, 0x07, 0x38, 0xad, 0x62, 0x92, 66 | 0x73, 0x87, 0x18, 0x1a, 0x00, 0x55, 0xaa, 0x17, 0x9e, 0x9a, 0x93, 0xe3, 0x9d, 0x97, 0x5f, 0x9e, 67 | 0x17, 0x02, 0xd2, 0x92, 0xc4, 0x06, 0x36, 0xc3, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xbb, 68 | 0xf4, 0x0e, 0xd2, 0x00, 0x00, 0x00, 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/empty/empty.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/empty"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "EmptyProto"; 39 | option java_multiple_files = true; 40 | option java_generate_equals_and_hash = true; 41 | option objc_class_prefix = "GPB"; 42 | option cc_enable_arenas = true; 43 | 44 | // A generic empty message that you can re-use to avoid defining duplicated 45 | // empty messages in your APIs. A typical example is to use it as the request 46 | // or the response type of an API method. For instance: 47 | // 48 | // service Foo { 49 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 50 | // } 51 | // 52 | // The JSON representation for `Empty` is empty JSON object `{}`. 53 | message Empty {} 54 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/regen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # This script fetches and rebuilds the "well-known types" protocol buffers. 4 | # To run this you will need protoc and goprotobuf installed; 5 | # see https://github.com/golang/protobuf for instructions. 6 | # You also need Go and Git installed. 7 | 8 | PKG=github.com/golang/protobuf/ptypes 9 | UPSTREAM=https://github.com/google/protobuf 10 | UPSTREAM_SUBDIR=src/google/protobuf 11 | PROTO_FILES=' 12 | any.proto 13 | duration.proto 14 | empty.proto 15 | struct.proto 16 | timestamp.proto 17 | wrappers.proto 18 | ' 19 | 20 | function die() { 21 | echo 1>&2 $* 22 | exit 1 23 | } 24 | 25 | # Sanity check that the right tools are accessible. 26 | for tool in go git protoc protoc-gen-go; do 27 | q=$(which $tool) || die "didn't find $tool" 28 | echo 1>&2 "$tool: $q" 29 | done 30 | 31 | tmpdir=$(mktemp -d -t regen-wkt.XXXXXX) 32 | trap 'rm -rf $tmpdir' EXIT 33 | 34 | echo -n 1>&2 "finding package dir... " 35 | pkgdir=$(go list -f '{{.Dir}}' $PKG) 36 | echo 1>&2 $pkgdir 37 | base=$(echo $pkgdir | sed "s,/$PKG\$,,") 38 | echo 1>&2 "base: $base" 39 | cd $base 40 | 41 | echo 1>&2 "fetching latest protos... " 42 | git clone -q $UPSTREAM $tmpdir 43 | # Pass 1: build mapping from upstream filename to our filename. 44 | declare -A filename_map 45 | for f in $(cd $PKG && find * -name '*.proto'); do 46 | echo -n 1>&2 "looking for latest version of $f... " 47 | up=$(cd $tmpdir/$UPSTREAM_SUBDIR && find * -name $(basename $f) | grep -v /testdata/) 48 | echo 1>&2 $up 49 | if [ $(echo $up | wc -w) != "1" ]; then 50 | die "not exactly one match" 51 | fi 52 | filename_map[$up]=$f 53 | done 54 | # Pass 2: copy files 55 | for up in "${!filename_map[@]}"; do 56 | f=${filename_map[$up]} 57 | shortname=$(basename $f | sed 's,\.proto$,,') 58 | cp $tmpdir/$UPSTREAM_SUBDIR/$up $PKG/$f 59 | done 60 | 61 | # Run protoc once per package. 62 | for dir in $(find $PKG -name '*.proto' | xargs dirname | sort | uniq); do 63 | echo 1>&2 "* $dir" 64 | protoc --go_out=. $dir/*.proto 65 | done 66 | echo 1>&2 "All OK" 67 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/struct/struct.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "StructProto"; 39 | option java_multiple_files = true; 40 | option java_generate_equals_and_hash = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | 44 | // `Struct` represents a structured data value, consisting of fields 45 | // which map to dynamically typed values. In some languages, `Struct` 46 | // might be supported by a native representation. For example, in 47 | // scripting languages like JS a struct is represented as an 48 | // object. The details of that representation are described together 49 | // with the proto support for the language. 50 | // 51 | // The JSON representation for `Struct` is JSON object. 52 | message Struct { 53 | // Unordered map of dynamically typed values. 54 | map fields = 1; 55 | } 56 | 57 | // `Value` represents a dynamically typed value which can be either 58 | // null, a number, a string, a boolean, a recursive struct value, or a 59 | // list of values. A producer of value is expected to set one of that 60 | // variants, absence of any variant indicates an error. 61 | // 62 | // The JSON representation for `Value` is JSON value. 63 | message Value { 64 | // The kind of value. 65 | oneof kind { 66 | // Represents a null value. 67 | NullValue null_value = 1; 68 | // Represents a double value. 69 | double number_value = 2; 70 | // Represents a string value. 71 | string string_value = 3; 72 | // Represents a boolean value. 73 | bool bool_value = 4; 74 | // Represents a structured value. 75 | Struct struct_value = 5; 76 | // Represents a repeated `Value`. 77 | ListValue list_value = 6; 78 | } 79 | } 80 | 81 | // `NullValue` is a singleton enumeration to represent the null value for the 82 | // `Value` type union. 83 | // 84 | // The JSON representation for `NullValue` is JSON `null`. 85 | enum NullValue { 86 | // Null value. 87 | NULL_VALUE = 0; 88 | } 89 | 90 | // `ListValue` is a wrapper around a repeated field of values. 91 | // 92 | // The JSON representation for `ListValue` is JSON array. 93 | message ListValue { 94 | // Repeated field of dynamically typed values. 95 | repeated Value values = 1; 96 | } 97 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/timestamp.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | // This file implements operations on google.protobuf.Timestamp. 35 | 36 | import ( 37 | "errors" 38 | "fmt" 39 | "time" 40 | 41 | tspb "github.com/golang/protobuf/ptypes/timestamp" 42 | ) 43 | 44 | const ( 45 | // Seconds field of the earliest valid Timestamp. 46 | // This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). 47 | minValidSeconds = -62135596800 48 | // Seconds field just after the latest valid Timestamp. 49 | // This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). 50 | maxValidSeconds = 253402300800 51 | ) 52 | 53 | // validateTimestamp determines whether a Timestamp is valid. 54 | // A valid timestamp represents a time in the range 55 | // [0001-01-01, 10000-01-01) and has a Nanos field 56 | // in the range [0, 1e9). 57 | // 58 | // If the Timestamp is valid, validateTimestamp returns nil. 59 | // Otherwise, it returns an error that describes 60 | // the problem. 61 | // 62 | // Every valid Timestamp can be represented by a time.Time, but the converse is not true. 63 | func validateTimestamp(ts *tspb.Timestamp) error { 64 | if ts == nil { 65 | return errors.New("timestamp: nil Timestamp") 66 | } 67 | if ts.Seconds < minValidSeconds { 68 | return fmt.Errorf("timestamp: %v before 0001-01-01", ts) 69 | } 70 | if ts.Seconds >= maxValidSeconds { 71 | return fmt.Errorf("timestamp: %v after 10000-01-01", ts) 72 | } 73 | if ts.Nanos < 0 || ts.Nanos >= 1e9 { 74 | return fmt.Errorf("timestamp: %v: nanos not in range [0, 1e9)", ts) 75 | } 76 | return nil 77 | } 78 | 79 | // Timestamp converts a google.protobuf.Timestamp proto to a time.Time. 80 | // It returns an error if the argument is invalid. 81 | // 82 | // Unlike most Go functions, if Timestamp returns an error, the first return value 83 | // is not the zero time.Time. Instead, it is the value obtained from the 84 | // time.Unix function when passed the contents of the Timestamp, in the UTC 85 | // locale. This may or may not be a meaningful time; many invalid Timestamps 86 | // do map to valid time.Times. 87 | // 88 | // A nil Timestamp returns an error. The first return value in that case is 89 | // undefined. 90 | func Timestamp(ts *tspb.Timestamp) (time.Time, error) { 91 | // Don't return the zero value on error, because corresponds to a valid 92 | // timestamp. Instead return whatever time.Unix gives us. 93 | var t time.Time 94 | if ts == nil { 95 | t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp 96 | } else { 97 | t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC() 98 | } 99 | return t, validateTimestamp(ts) 100 | } 101 | 102 | // TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. 103 | // It returns an error if the resulting Timestamp is invalid. 104 | func TimestampProto(t time.Time) (*tspb.Timestamp, error) { 105 | seconds := t.Unix() 106 | nanos := int32(t.Sub(time.Unix(seconds, 0))) 107 | ts := &tspb.Timestamp{ 108 | Seconds: seconds, 109 | Nanos: nanos, 110 | } 111 | if err := validateTimestamp(ts); err != nil { 112 | return nil, err 113 | } 114 | return ts, nil 115 | } 116 | 117 | // TimestampString returns the RFC 3339 string for valid Timestamps. For invalid 118 | // Timestamps, it returns an error message in parentheses. 119 | func TimestampString(ts *tspb.Timestamp) string { 120 | t, err := Timestamp(ts) 121 | if err != nil { 122 | return fmt.Sprintf("(%v)", err) 123 | } 124 | return t.Format(time.RFC3339Nano) 125 | } 126 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: github.com/golang/protobuf/ptypes/timestamp/timestamp.proto 3 | // DO NOT EDIT! 4 | 5 | /* 6 | Package timestamp is a generated protocol buffer package. 7 | 8 | It is generated from these files: 9 | github.com/golang/protobuf/ptypes/timestamp/timestamp.proto 10 | 11 | It has these top-level messages: 12 | Timestamp 13 | */ 14 | package timestamp 15 | 16 | import proto "github.com/golang/protobuf/proto" 17 | import fmt "fmt" 18 | import math "math" 19 | 20 | // Reference imports to suppress errors if they are not otherwise used. 21 | var _ = proto.Marshal 22 | var _ = fmt.Errorf 23 | var _ = math.Inf 24 | 25 | // This is a compile-time assertion to ensure that this generated file 26 | // is compatible with the proto package it is being compiled against. 27 | // A compilation error at this line likely means your copy of the 28 | // proto package needs to be updated. 29 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 30 | 31 | // A Timestamp represents a point in time independent of any time zone 32 | // or calendar, represented as seconds and fractions of seconds at 33 | // nanosecond resolution in UTC Epoch time. It is encoded using the 34 | // Proleptic Gregorian Calendar which extends the Gregorian calendar 35 | // backwards to year one. It is encoded assuming all minutes are 60 36 | // seconds long, i.e. leap seconds are "smeared" so that no leap second 37 | // table is needed for interpretation. Range is from 38 | // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. 39 | // By restricting to that range, we ensure that we can convert to 40 | // and from RFC 3339 date strings. 41 | // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). 42 | // 43 | // Example 1: Compute Timestamp from POSIX `time()`. 44 | // 45 | // Timestamp timestamp; 46 | // timestamp.set_seconds(time(NULL)); 47 | // timestamp.set_nanos(0); 48 | // 49 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 50 | // 51 | // struct timeval tv; 52 | // gettimeofday(&tv, NULL); 53 | // 54 | // Timestamp timestamp; 55 | // timestamp.set_seconds(tv.tv_sec); 56 | // timestamp.set_nanos(tv.tv_usec * 1000); 57 | // 58 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 59 | // 60 | // FILETIME ft; 61 | // GetSystemTimeAsFileTime(&ft); 62 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 63 | // 64 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 65 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 66 | // Timestamp timestamp; 67 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 68 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 69 | // 70 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 71 | // 72 | // long millis = System.currentTimeMillis(); 73 | // 74 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 75 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 76 | // 77 | // 78 | // Example 5: Compute Timestamp from current time in Python. 79 | // 80 | // now = time.time() 81 | // seconds = int(now) 82 | // nanos = int((now - seconds) * 10**9) 83 | // timestamp = Timestamp(seconds=seconds, nanos=nanos) 84 | // 85 | // 86 | type Timestamp struct { 87 | // Represents seconds of UTC time since Unix epoch 88 | // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to 89 | // 9999-12-31T23:59:59Z inclusive. 90 | Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` 91 | // Non-negative fractions of a second at nanosecond resolution. Negative 92 | // second values with fractions must still have non-negative nanos values 93 | // that count forward in time. Must be from 0 to 999,999,999 94 | // inclusive. 95 | Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"` 96 | } 97 | 98 | func (m *Timestamp) Reset() { *m = Timestamp{} } 99 | func (m *Timestamp) String() string { return proto.CompactTextString(m) } 100 | func (*Timestamp) ProtoMessage() {} 101 | func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } 102 | func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } 103 | 104 | func init() { 105 | proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") 106 | } 107 | 108 | func init() { 109 | proto.RegisterFile("github.com/golang/protobuf/ptypes/timestamp/timestamp.proto", fileDescriptor0) 110 | } 111 | 112 | var fileDescriptor0 = []byte{ 113 | // 194 bytes of a gzipped FileDescriptorProto 114 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4e, 0xcf, 0x2c, 0xc9, 115 | 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, 116 | 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0xc9, 117 | 0xcc, 0x4d, 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0x40, 0xb0, 0xf4, 0xc0, 0x6a, 0x84, 0xf8, 0xd3, 0xf3, 118 | 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x60, 0x3a, 0x94, 0xac, 0xb9, 0x38, 0x43, 0x60, 0x6a, 0x84, 0x24, 119 | 0xb8, 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 120 | 0x60, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d, 121 | 0xd6, 0x20, 0x08, 0xc7, 0xa9, 0x91, 0x91, 0x4b, 0x38, 0x39, 0x3f, 0x57, 0x0f, 0xcd, 0x50, 0x27, 122 | 0x3e, 0xb8, 0x91, 0x01, 0x20, 0xa1, 0x00, 0xc6, 0x28, 0x6d, 0x12, 0x1c, 0xbd, 0x80, 0x91, 0xf1, 123 | 0x07, 0x23, 0xe3, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7, 0x55, 0x4c, 0x72, 0xee, 0x10, 0xc3, 0x03, 124 | 0xa0, 0xca, 0xf5, 0xc2, 0x53, 0x73, 0x72, 0xbc, 0xf3, 0xf2, 0xcb, 0xf3, 0x42, 0x40, 0xda, 0x92, 125 | 0xd8, 0xc0, 0xe6, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x17, 0x5f, 0xb7, 0xdc, 0x17, 0x01, 126 | 0x00, 0x00, 127 | } 128 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/timestamp"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "TimestampProto"; 40 | option java_multiple_files = true; 41 | option java_generate_equals_and_hash = true; 42 | option objc_class_prefix = "GPB"; 43 | 44 | // A Timestamp represents a point in time independent of any time zone 45 | // or calendar, represented as seconds and fractions of seconds at 46 | // nanosecond resolution in UTC Epoch time. It is encoded using the 47 | // Proleptic Gregorian Calendar which extends the Gregorian calendar 48 | // backwards to year one. It is encoded assuming all minutes are 60 49 | // seconds long, i.e. leap seconds are "smeared" so that no leap second 50 | // table is needed for interpretation. Range is from 51 | // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. 52 | // By restricting to that range, we ensure that we can convert to 53 | // and from RFC 3339 date strings. 54 | // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). 55 | // 56 | // Example 1: Compute Timestamp from POSIX `time()`. 57 | // 58 | // Timestamp timestamp; 59 | // timestamp.set_seconds(time(NULL)); 60 | // timestamp.set_nanos(0); 61 | // 62 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 63 | // 64 | // struct timeval tv; 65 | // gettimeofday(&tv, NULL); 66 | // 67 | // Timestamp timestamp; 68 | // timestamp.set_seconds(tv.tv_sec); 69 | // timestamp.set_nanos(tv.tv_usec * 1000); 70 | // 71 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 72 | // 73 | // FILETIME ft; 74 | // GetSystemTimeAsFileTime(&ft); 75 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 76 | // 77 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 78 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 79 | // Timestamp timestamp; 80 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 81 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 82 | // 83 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 84 | // 85 | // long millis = System.currentTimeMillis(); 86 | // 87 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 88 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 89 | // 90 | // 91 | // Example 5: Compute Timestamp from current time in Python. 92 | // 93 | // now = time.time() 94 | // seconds = int(now) 95 | // nanos = int((now - seconds) * 10**9) 96 | // timestamp = Timestamp(seconds=seconds, nanos=nanos) 97 | // 98 | // 99 | message Timestamp { 100 | 101 | // Represents seconds of UTC time since Unix epoch 102 | // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to 103 | // 9999-12-31T23:59:59Z inclusive. 104 | int64 seconds = 1; 105 | 106 | // Non-negative fractions of a second at nanosecond resolution. Negative 107 | // second values with fractions must still have non-negative nanos values 108 | // that count forward in time. Must be from 0 to 999,999,999 109 | // inclusive. 110 | int32 nanos = 2; 111 | } 112 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/timestamp_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package ptypes 33 | 34 | import ( 35 | "math" 36 | "testing" 37 | "time" 38 | 39 | "github.com/golang/protobuf/proto" 40 | tspb "github.com/golang/protobuf/ptypes/timestamp" 41 | ) 42 | 43 | var tests = []struct { 44 | ts *tspb.Timestamp 45 | valid bool 46 | t time.Time 47 | }{ 48 | // The timestamp representing the Unix epoch date. 49 | {&tspb.Timestamp{0, 0}, true, utcDate(1970, 1, 1)}, 50 | // The smallest representable timestamp. 51 | {&tspb.Timestamp{math.MinInt64, math.MinInt32}, false, 52 | time.Unix(math.MinInt64, math.MinInt32).UTC()}, 53 | // The smallest representable timestamp with non-negative nanos. 54 | {&tspb.Timestamp{math.MinInt64, 0}, false, time.Unix(math.MinInt64, 0).UTC()}, 55 | // The earliest valid timestamp. 56 | {&tspb.Timestamp{minValidSeconds, 0}, true, utcDate(1, 1, 1)}, 57 | //"0001-01-01T00:00:00Z"}, 58 | // The largest representable timestamp. 59 | {&tspb.Timestamp{math.MaxInt64, math.MaxInt32}, false, 60 | time.Unix(math.MaxInt64, math.MaxInt32).UTC()}, 61 | // The largest representable timestamp with nanos in range. 62 | {&tspb.Timestamp{math.MaxInt64, 1e9 - 1}, false, 63 | time.Unix(math.MaxInt64, 1e9-1).UTC()}, 64 | // The largest valid timestamp. 65 | {&tspb.Timestamp{maxValidSeconds - 1, 1e9 - 1}, true, 66 | time.Date(9999, 12, 31, 23, 59, 59, 1e9-1, time.UTC)}, 67 | // The smallest invalid timestamp that is larger than the valid range. 68 | {&tspb.Timestamp{maxValidSeconds, 0}, false, time.Unix(maxValidSeconds, 0).UTC()}, 69 | // A date before the epoch. 70 | {&tspb.Timestamp{-281836800, 0}, true, utcDate(1961, 1, 26)}, 71 | // A date after the epoch. 72 | {&tspb.Timestamp{1296000000, 0}, true, utcDate(2011, 1, 26)}, 73 | // A date after the epoch, in the middle of the day. 74 | {&tspb.Timestamp{1296012345, 940483}, true, 75 | time.Date(2011, 1, 26, 3, 25, 45, 940483, time.UTC)}, 76 | } 77 | 78 | func TestValidateTimestamp(t *testing.T) { 79 | for _, s := range tests { 80 | got := validateTimestamp(s.ts) 81 | if (got == nil) != s.valid { 82 | t.Errorf("validateTimestamp(%v) = %v, want %v", s.ts, got, s.valid) 83 | } 84 | } 85 | } 86 | 87 | func TestTimestamp(t *testing.T) { 88 | for _, s := range tests { 89 | got, err := Timestamp(s.ts) 90 | if (err == nil) != s.valid { 91 | t.Errorf("Timestamp(%v) error = %v, but valid = %t", s.ts, err, s.valid) 92 | } else if s.valid && got != s.t { 93 | t.Errorf("Timestamp(%v) = %v, want %v", s.ts, got, s.t) 94 | } 95 | } 96 | // Special case: a nil Timestamp is an error, but returns the 0 Unix time. 97 | got, err := Timestamp(nil) 98 | want := time.Unix(0, 0).UTC() 99 | if got != want { 100 | t.Errorf("Timestamp(nil) = %v, want %v", got, want) 101 | } 102 | if err == nil { 103 | t.Errorf("Timestamp(nil) error = nil, expected error") 104 | } 105 | } 106 | 107 | func TestTimestampProto(t *testing.T) { 108 | for _, s := range tests { 109 | got, err := TimestampProto(s.t) 110 | if (err == nil) != s.valid { 111 | t.Errorf("TimestampProto(%v) error = %v, but valid = %t", s.t, err, s.valid) 112 | } else if s.valid && !proto.Equal(got, s.ts) { 113 | t.Errorf("TimestampProto(%v) = %v, want %v", s.t, got, s.ts) 114 | } 115 | } 116 | // No corresponding special case here: no time.Time results in a nil Timestamp. 117 | } 118 | 119 | func TestTimestampString(t *testing.T) { 120 | for _, test := range []struct { 121 | ts *tspb.Timestamp 122 | want string 123 | }{ 124 | // Not much testing needed because presumably time.Format is 125 | // well-tested. 126 | {&tspb.Timestamp{0, 0}, "1970-01-01T00:00:00Z"}, 127 | {&tspb.Timestamp{minValidSeconds - 1, 0}, "(timestamp: seconds:-62135596801 before 0001-01-01)"}, 128 | } { 129 | got := TimestampString(test.ts) 130 | if got != test.want { 131 | t.Errorf("TimestampString(%v) = %q, want %q", test.ts, got, test.want) 132 | } 133 | } 134 | } 135 | 136 | func utcDate(year, month, day int) time.Time { 137 | return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC) 138 | } 139 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Wrappers for primitive (non-message) types. These types are useful 32 | // for embedding primitives in the `google.protobuf.Any` type and for places 33 | // where we need to distinguish between the absence of a primitive 34 | // typed field and its default value. 35 | 36 | syntax = "proto3"; 37 | 38 | package google.protobuf; 39 | 40 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 41 | option cc_enable_arenas = true; 42 | option go_package = "github.com/golang/protobuf/ptypes/wrappers"; 43 | option java_package = "com.google.protobuf"; 44 | option java_outer_classname = "WrappersProto"; 45 | option java_multiple_files = true; 46 | option java_generate_equals_and_hash = true; 47 | option objc_class_prefix = "GPB"; 48 | 49 | // Wrapper message for `double`. 50 | // 51 | // The JSON representation for `DoubleValue` is JSON number. 52 | message DoubleValue { 53 | // The double value. 54 | double value = 1; 55 | } 56 | 57 | // Wrapper message for `float`. 58 | // 59 | // The JSON representation for `FloatValue` is JSON number. 60 | message FloatValue { 61 | // The float value. 62 | float value = 1; 63 | } 64 | 65 | // Wrapper message for `int64`. 66 | // 67 | // The JSON representation for `Int64Value` is JSON string. 68 | message Int64Value { 69 | // The int64 value. 70 | int64 value = 1; 71 | } 72 | 73 | // Wrapper message for `uint64`. 74 | // 75 | // The JSON representation for `UInt64Value` is JSON string. 76 | message UInt64Value { 77 | // The uint64 value. 78 | uint64 value = 1; 79 | } 80 | 81 | // Wrapper message for `int32`. 82 | // 83 | // The JSON representation for `Int32Value` is JSON number. 84 | message Int32Value { 85 | // The int32 value. 86 | int32 value = 1; 87 | } 88 | 89 | // Wrapper message for `uint32`. 90 | // 91 | // The JSON representation for `UInt32Value` is JSON number. 92 | message UInt32Value { 93 | // The uint32 value. 94 | uint32 value = 1; 95 | } 96 | 97 | // Wrapper message for `bool`. 98 | // 99 | // The JSON representation for `BoolValue` is JSON `true` and `false`. 100 | message BoolValue { 101 | // The bool value. 102 | bool value = 1; 103 | } 104 | 105 | // Wrapper message for `string`. 106 | // 107 | // The JSON representation for `StringValue` is JSON string. 108 | message StringValue { 109 | // The string value. 110 | string value = 1; 111 | } 112 | 113 | // Wrapper message for `bytes`. 114 | // 115 | // The JSON representation for `BytesValue` is JSON string. 116 | message BytesValue { 117 | // The bytes value. 118 | bytes value = 1; 119 | } 120 | --------------------------------------------------------------------------------