Merge pull request #57 from moul/dev/moul/go-generate-example

Add go:generate example
This commit is contained in:
Manfred Touron 2017-04-24 11:35:01 +02:00 committed by GitHub
commit c73a4b8c46
7 changed files with 137 additions and 0 deletions

View File

@ -13,6 +13,7 @@ test: build
cd examples/concat && make
cd examples/flow && make
cd examples/sitemap && make
cd examples/go-generate && make
# cd examples/go-kit && make
.PHONY: docker.build

View File

@ -0,0 +1,2 @@
all:
go generate

View File

@ -0,0 +1,4 @@
package example
//go:generate protoc --go_out=./gen/ example.proto
//go:generate protoc --gotemplate_out=./gen/ example.proto

View File

@ -0,0 +1,16 @@
syntax = "proto3";
package example;
service Sum {
rpc Sum(SumRequest) returns (SumReply) {};
}
message SumRequest {
int32 a = 1;
int32 b = 2;
}
message SumReply {
int32 c = 1;
}

View File

@ -0,0 +1,11 @@
// Code generated by protoc-gen-gotemplate
package example
// Methods
// -------
// * Sum
//
// Message types
// -------------
// * SumRequest
// * SumReply

View File

@ -0,0 +1,89 @@
// Code generated by protoc-gen-go.
// source: example.proto
// DO NOT EDIT!
/*
Package example is a generated protocol buffer package.
It is generated from these files:
example.proto
It has these top-level messages:
SumRequest
SumReply
*/
package example
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type SumRequest struct {
A int32 `protobuf:"varint,1,opt,name=a" json:"a,omitempty"`
B int32 `protobuf:"varint,2,opt,name=b" json:"b,omitempty"`
}
func (m *SumRequest) Reset() { *m = SumRequest{} }
func (m *SumRequest) String() string { return proto.CompactTextString(m) }
func (*SumRequest) ProtoMessage() {}
func (*SumRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *SumRequest) GetA() int32 {
if m != nil {
return m.A
}
return 0
}
func (m *SumRequest) GetB() int32 {
if m != nil {
return m.B
}
return 0
}
type SumReply struct {
C int32 `protobuf:"varint,1,opt,name=c" json:"c,omitempty"`
}
func (m *SumReply) Reset() { *m = SumReply{} }
func (m *SumReply) String() string { return proto.CompactTextString(m) }
func (*SumReply) ProtoMessage() {}
func (*SumReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *SumReply) GetC() int32 {
if m != nil {
return m.C
}
return 0
}
func init() {
proto.RegisterType((*SumRequest)(nil), "example.SumRequest")
proto.RegisterType((*SumReply)(nil), "example.SumReply")
}
func init() { proto.RegisterFile("example.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 124 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0xad, 0x48, 0xcc,
0x2d, 0xc8, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x72, 0x95, 0x34, 0xb8,
0xb8, 0x82, 0x4b, 0x73, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x84, 0x78, 0xb8, 0x18, 0x13,
0x25, 0x18, 0x15, 0x18, 0x35, 0x58, 0x83, 0x18, 0x13, 0x41, 0xbc, 0x24, 0x09, 0x26, 0x08, 0x2f,
0x49, 0x49, 0x82, 0x8b, 0x03, 0xac, 0xb2, 0x20, 0xa7, 0x12, 0x24, 0x93, 0x0c, 0x53, 0x97, 0x6c,
0x64, 0xc6, 0xc5, 0x1c, 0x5c, 0x9a, 0x2b, 0xa4, 0x0f, 0xa1, 0x84, 0xf5, 0x60, 0x56, 0x21, 0x0c,
0x96, 0x12, 0x44, 0x15, 0x2c, 0xc8, 0xa9, 0x54, 0x62, 0x48, 0x62, 0x03, 0xbb, 0xc5, 0x18, 0x10,
0x00, 0x00, 0xff, 0xff, 0x2b, 0xf1, 0xe9, 0x56, 0x9c, 0x00, 0x00, 0x00,
}

View File

@ -0,0 +1,14 @@
// Code generated by protoc-gen-gotemplate
package {{.File.Package}}
// Methods
// -------
{{- range .Service.Method}}
// * {{.Name}}
{{- end}}
//
// Message types
// -------------
{{- range .File.MessageType}}
// * {{.Name}}
{{- end}}