From 5fc2294e655b78ed8a02082d37808d46c17d7e64 Mon Sep 17 00:00:00 2001 From: David Symonds Date: Thu, 21 Jan 2016 14:29:00 +1100 Subject: [PATCH] Clarify jsonpb package docs. --- jsonpb/jsonpb.go | 9 ++++----- protoc-gen-go/generator/generator.go | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jsonpb/jsonpb.go b/jsonpb/jsonpb.go index 57b58fd3..4c22d212 100644 --- a/jsonpb/jsonpb.go +++ b/jsonpb/jsonpb.go @@ -30,12 +30,11 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* -Package jsonpb provides marshaling/unmarshaling functionality between -protocol buffer and JSON objects. +Package jsonpb provides marshaling and unmarshaling between protocol buffers and JSON. +It follows the specification at https://developers.google.com/protocol-buffers/docs/proto3#json. -Compared to encoding/json, this library: - - encodes int64, uint64 as strings - - optionally encodes enums as integers +This package produces a different output than the standard "encoding/json" package, +which does not operate correctly on protocol buffers. */ package jsonpb diff --git a/protoc-gen-go/generator/generator.go b/protoc-gen-go/generator/generator.go index c2c96bf7..0f7a3373 100644 --- a/protoc-gen-go/generator/generator.go +++ b/protoc-gen-go/generator/generator.go @@ -2541,7 +2541,9 @@ func (g *Generator) generateFileDescriptor(file *FileDescriptor) { w.Close() b = buf.Bytes() - g.P("var fileDescriptor", file.index, " = []byte{") + v := fmt.Sprintf("fileDescriptor%d", file.index) + g.P() + g.P("var ", v, " = []byte{") g.In() g.P("// ", len(b), " bytes of a gzipped FileDescriptorProto") for len(b) > 0 {