Proto commits in golang/protobuf

These commits are when the Protocol Buffers files have changed: (only the last 100 relevant commits are shown)

Commit:37828f9
Author:Damien Neil

jsonpb: accept 'null' as a valid representation of NullValue in unmarshal The canonical JSON representation for NullValue is JSON "null". Fixes github.com/golang/protobuf#1361.

The documentation is generated from this commit.

Commit:5d5b4c1
Author:Damien Neil
Committer:GitHub

ptypes: regenerate with v3.11.4, update for go1.14 gofmt (#1045) Update .proto files to github.com/protocolbuffers v3.11.4. Add go1.13 and go1.14 to .travis.yml. Avoid one-line funcs in protoc-gen-go output to prevent variable post-gofmt output with go1.14.

Commit:4767034
Author:Damien Neil
Committer:Damien Neil

protoc-gen-go: drop golden test Doesn't work in CI, since we don't have protoc available. Only tests the gRPC generator, which is moving to the gRPC repo soon anyway. Just drop it. Change-Id: Ie0c5ddf1cc1ab4268838f3ea18ca2410cfe6d698 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220497 Reviewed-by: Joe Tsai <joetsai@google.com>

Commit:cea45d6
Author:Damien Neil
Committer:Damien Neil

protoc-gen-go: move gengogrpc into v1 repo The eventual home of this is the gRPC repo, but extract it from the APIv2 repo for now. Change-Id: I0d88659945e17887da117ab6511e478598e70f02 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220354 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>

Commit:cc376d7
Author:Joe Tsai
Committer:Joe Tsai

all: update to wrap v2 All functionality has been re-written to either wrap v2 directly (e.g., binary serialization) or written to use v2 protobuf reflection (e.g., text and json serialization). This is to done to reduce the technical debt of maintaining the v1 module. Change-Id: I6749fa58a465df991c8fcf89e8d7077d64a2cfdb Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/213901 Reviewed-by: Damien Neil <dneil@google.com>

Commit:d3c38a4
Author:Joe Tsai
Committer:Damien Neil

protoc-gen-go/grpc: use status and code packages only if needed (#820) In the rare event that a proto file only has a service declaration with no declared methods, it will not depend on status and code. Make sure these are not imported in such cases.

Commit:f5983a5
Author:Joe Tsai
Committer:Joe Tsai

internal/cmd/generate-alias: directly invoke v2 internal_gengo Now that Cl/167768 removed the dependency on protoc for the generated test protos, the only remaining dependency is on protoc is for the import public aliases. However, we observe that we can avoid protoc since we already have the file descriptor on hand for the remote targets. Using that, we can invoke internal_gengo directly and circumvent any need for protoc. With protoc no longer being a dependency, the integration script loses its value, so can be deleted. Change-Id: I522c1e4f2abc47be2817f3bd6b3ff9704b0abb83 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167770 Reviewed-by: Herbie Ong <herbie@google.com>

Commit:f41bc14
Author:Joe Tsai
Committer:Joe Tsai

test.bash: re-write integration test as a Go test This change: * upgrades the v2 dependency to the latest version * copies integration_test.go from v2 and deletes irrelevant code. * copies internal/cmd/generate-protos from v2 and deletes irrelevant code and modifies generateLocalProtos accordingly * deletes protoc-gen-go/testdata since this is covered in v2 * uses import public to alias the v2 version of the well-known types, plugin proto, and descriptor proto Change-Id: Ib1d4280afaca8a811b9ff57792e02b15b3b8f0ec Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167141 Reviewed-by: Herbie Ong <herbie@google.com>

Commit:b5d812f
Author:Joe Tsai
Committer:GitHub

Delete the conformance test (#808) The conformance test is hard to run and heavily dependant on the exact version of protoc installed on the developer's workstation. Delete this from the v1 and leave conformance testing to v2, which has infrastructure built for stricter control over dependencies.

Commit:347cf4a
Author:Joe Tsai
Committer:GitHub

protoc-gen-go: fix oneof name mangling regression (#782) The generator currently uses an unintuitive and stateful algorithm for name generation where it "fixes" name conflicts by appending "_" to the end of the new name. PR#657 refactored the generator code and noticed that the above algorithm was not properly taking into account that a Get method is generated for parent oneofs, fixing it in the same PR. While this is more correct, this breaks users (see #780) since it means that the generation of names can change. This PR changes the name mangling logic to be as it was previously. This does mean that some new proto files may be unbuildable, but that is arguably better than breaking existing proto files. Fixes #780

Commit:eef680e
Author:Joe Tsai
Committer:Joe Tsai

conformance: remove the conformance test The conformance test will eventually live in the v2 repository. Remove it from v1. It does not even work anymore and is not worth fixing up. Change-Id: I39b5b615becdd294306d5782ab37c94a5bd7713a Reviewed-on: https://go-review.googlesource.com/c/151406 Reviewed-by: Herbie Ong <herbie@google.com>

Commit:e21ef87
Author:Joe Tsai
Committer:Joe Tsai

all: update to v3.6.1 (#757) Update all proto files that is obtained from the upstream repository to v3.6.1. Change-Id: I18110fc1f20792b8258126eb91e8345d566211d8 Cherry-Pick: github.com/golang/protobuf@882cf97a83ad205fd22af574246a3bc647d7a7d2 Original-Author: Joe Tsai <joetsai@digital-static.net> Reviewed-on: https://go-review.googlesource.com/c/151457 Reviewed-by: Damien Neil <dneil@google.com>

Commit:95590b6
Author:Joe Tsai
Committer:Joe Tsai

protoc-gen-go: add test for use of publicly imported symbol Test the following case: File 1 defines a symbol S. File 2 publicly imports file 1. File 3 imports file 2 and uses S. All files in different Go packages: P1, P2, P3. Note that the .pb.go for file 3 could import P1 or P2, since the symbol is defined in both. Change-Id: I1f1d21dcb7b19a348859531a283e0adcb1619796 Cherry-Pick: github.com/golang/protobuf@9a73c7ffd8c7ee685c98283cda9c46d4f28f6d19 Original-Author: Damien Neil <dneil@google.com> Reviewed-on: https://go-review.googlesource.com/c/151432 Reviewed-by: Damien Neil <dneil@google.com>

Commit:f27b90d
Author:Joe Tsai
Committer:Joe Tsai

protoc-gen-go: expand import_public test files Convert all the import_public protos to proto2 to allow testing more features. Add usage of groups, extensions, and default values. Change-Id: I5b65caa94fad13a34e63568f5fad6a6510a5fbc7 Cherry-Pick: github.com/golang/protobuf@d18af0db6e2578f79abd903de10223e411a6479d Original-Author: Damien Neil <dneil@google.com> Reviewed-on: https://go-review.googlesource.com/c/151430 Reviewed-by: Damien Neil <dneil@google.com>

Commit:4e2754b
Author:Joe Tsai
Committer:Joe Tsai

protoc-gen-go: normalize floating-point default values (#737) Parse floating-point default values and format them with fmt.Sprint. Eliminates a minor point of inconsistency with the v2 generator. Change-Id: I153318f1760bac878cb0303301bed7e4bafe3431 Cherry-Pick: github.com/golang/protobuf@d3de96c4c28ef8af3aa1a892fc481e0f103c01ff Original-Author: Damien Neil <neild@users.noreply.github.com> Reviewed-on: https://go-review.googlesource.com/c/151429 Reviewed-by: Damien Neil <dneil@google.com>

Commit:04a0f24
Author:Joe Tsai
Committer:Joe Tsai

protoc-gen-go: add test case for deprecated oneof field Change-Id: I444147547ccfcedce722ccccd9fb229aa8aa1128 Cherry-Pick: github.com/golang/protobuf@3ed0fc6514d1378a29be51817ec3a195b5e25864 Original-Author: Damien Neil <dneil@google.com> Reviewed-on: https://go-review.googlesource.com/c/151427 Reviewed-by: Damien Neil <dneil@google.com>

Commit:882cf97
Author:Joe Tsai
Committer:GitHub

all: update to v3.6.1 (#757) Update all proto files that is obtained from the upstream repository to v3.6.1.

Commit:9a73c7f
Author:Damien Neil
Committer:Damien Neil

protoc-gen-go: add test for use of publicly imported symbol Test the following case: File 1 defines a symbol S. File 2 publicly imports file 1. File 3 imports file 2 and uses S. All files in different Go packages: P1, P2, P3. Note that the .pb.go for file 3 could import P1 or P2, since the symbol is defined in both.

Commit:d18af0d
Author:Damien Neil
Committer:Damien Neil

protoc-gen-go: expand import_public test files Convert all the import_public protos to proto2 to allow testing more features. Add usage of groups, extensions, and default values.

Commit:d3de96c
Author:Damien Neil
Committer:GitHub

protoc-gen-go: normalize floating-point default values (#737) Parse floating-point default values and format them with fmt.Sprint. Eliminates a minor point of inconsistency with the v2 generator.

Commit:3ed0fc6
Author:Damien Neil
Committer:Damien Neil

protoc-gen-go: add test case for deprecated oneof field

Commit:e6eece4
Author:Damien Neil
Committer:Damien Neil

protoc-gen-go: additional tests for public imports Adds cases for importing nested messages, nested enums, and oneofs.

Commit:427e165
Author:Joe Tsai
Committer:GitHub

proto: fix and cleanup test for deterministic marshal with custom marshalers (#656) PR #650 added a check to error out when a custom marshaler was called and deterministic marshaling was also specified. That change performed the check in a relatively obscure location that did not catch all code paths. Since determinism can only be enabled on the Buffer type, we check it up front in Buffer.Marshal. Also, change the test to avoid code injection into generated sources.

Commit:70b3af3
Author:jmarais
Committer:Joe Tsai

proto: return errors when using deterministic marshaling with custom Marshalers Custom marshalers cannot report that they are definitely deterministic. It is better to report that this is not supported than to give undefined behavior.

Commit:9eb2c01
Author:Kassian Sun
Committer:Joe Tsai

jsonpb: decode int32/uint32/float32/float64 strings (#630) According to https://developers.google.com/protocol-buffers/docs/proto3#json, all integers & floats are accepted as strings.

Commit:05f48f4
Author:Joe Tsai
Committer:GitHub

proto: revert UTF-8 validation for proto2 (#628) The proto specification officially says that proto2 and proto3 strings should be validated, but pragmatically, compliance with the spec has been poor. For example, the Go implementation did not validate either and added strict validation recently to be compliant. However, this caused signficant breakage. Cases of breakage should change the proto field type from string to the bytes type. However, this is not always possible, when the field is part of the exposed API. This tends to be the case for proto2, where some other notable language implementations (like C++) do not validate proto2 for valid UTF-8. However, since most language implementations do validate for UTF-8 in proto3, we keep that behavior. Making this change for Go is a little tricky since each field does not necessarily know whether it is operating under the proto2 or proto3 syntax. Thus, we modify the generator to emit a "proto3" struct field tag for all fields in proto3. The implications of this change is that people will need to regenerate their proto files to have UTF-8 validation. We expand UTF-8 validation tests to ensure this works for the cross-product of (proto2, proto3) and (scalar, vector, oneof, and maps) fields with strings. Fixes #622

Commit:6fb5325
Author:Damien Neil
Committer:GitHub

Implement "import public" using type aliases. (#583) Type aliases were added in Go 1.9, so this change bumps the minium required Go version for protos which use public imports.

Commit:9bb8760
Author:Damien Neil
Committer:GitHub

protoc-gen-go: fix generation of proxy getters for distant types (#563) Skip generating getters for fields that are not defined in the same file as the publicly imported message. This is the wrong way to fix this problem. It is, however, the expedient one to hold us over until (soon, I hope) we completely redo public imports as type aliases and make all of this moot. The scenario: a.proto publicly imports b.proto b.proto has a message M M has a field F of type T We generate forwarding methods for public imports. // T is defined in the same Go package as a.proto. func (m *M) GetF() T { ... } Depending on what package T is defined in, we might need to qualify its name (foo.T), and we might need to add an import for that package. That's not what we used to do, however: Instead, we'd *only* generate the GetF forwarder if T is defined in b.proto. Commit 9d4962b4 made it so that we'd generate the forwarder if it T is defined in the *same Go package* as b.proto, which seems safe and reasonable. It turns out that something elsewhere in the generator is getting confused by this, however. Rather than figuring out what--which would also change a lot of generated code by adding forwarding methods that didn't used to be there--this just reverts back to the behavior of looking at files rather than packages. All of this goes away completely once we start using type aliases, because we don't need any forwarding methods at all at that point.

Commit:e09c5db
Author:John McCabe
Committer:Damien Neil

Fix godoc examples for Any (#569) An extra space was causing Examples 3 and 4 to render in Example 2's code block. This commit fixes those minor typos. Also removing the `====` denoting the JSON section will allow godoc to render a heading here. Signed-off-by: John McCabe <john@johnmccabe.net>

Commit:b028a76
Author:Joe Tsai
Committer:GitHub

proto: ignore unknown fields in map entries (#561) A proto map entry is conceptually a message with two fields. In the same way that unknown fields don't cause a parsing error, map parsing should ignore unknown fields and tags. Similarly, it treats a missing field as the zero value. Fixes #403

Commit:ab964bf
Author:Damien Neil
Committer:GitHub

conformance: clean up, fix conformance tests (#552) Move _conformance directory to conformance. (The _ was apparently there to prevent "go install ./..." from touching that directory, which doesn't seem like a sufficient reason to have a weird path name.) Delete conformance_proto directory, regenerate the proto at test time. (This proto is used for communications between the test runner and test process; nothing else needs it.) Add a list of known failures. Add a Makefile so that "make test" in the conformance directory does the right thing. (Requires that github.com/google/protobuf be installed somewhere.) Include documentation in "make all" output. Skip tests if the necessary dependencies don't exist.

Commit:80c8f76
Author:Damien Neil
Committer:GitHub

protoc-gen-go: fix generation of public imports (#549) (*Generator).DefaultPackageName returns either a qualified ("pkg.name") or unqualified ("name") name. Prior to commit 9d4962b4, it based this decision on whether the name was in the package we're generating code for. After this commit, it bases this on whether the name is in the file we're currently generating code for. i.e., what was once an invariant across all files is no longer. This is mostly fine, except for one case: We run the generator across files we do not generate code for, in order to build a list of symbols used to generate code for public imports. This change caused some of those symbols to no longer be qualified. In particular, this causes bad generation for wrapper types of publicly imported messages that contain a field whose type is another message in the same publicly imported package. Fix this. Clean up some effectively dead code in SetPackageNames at the same time. Fix tests to catch this case. (It wouldn't have caught it anyway, but imp.proto is supposed to contain a public import. This seems to have been lost when exporting code to git. Fixed.)

Commit:d0dc0de
Author:David Symonds
Committer:Joe Tsai

Reduce a bunch of generated code in oneof sizers. (#557) There's no need for oneof sizers to compute the size of the tag/wire varint, since it can be computed at proto compile time instead (and it is typically a small number like 1 or 2).

Commit:251359b
Author:Damien Neil
Committer:GitHub

protobuf: Delete makefiles, regenerate protos consistently (#546) Delete all the Makefiles except for the top-level one. Recursive make is difficult to understand, keeping all the Makefiles in sync is difficult (as witness the fact that there were numerous inconsistencies between them), and mostly they just ran trivial commands like "go test". Replace all regeneration of .pb.go files with a single regenerate.sh shell script. Stop relying on the protobuf repository being installed in ~/src/protobuf. The only things we need out of the repository are standard .proto source files, which protoc is perfectly capable of discovering on its own. Regenerate .pb.go files which had been missed by "make regenerate" before.

Commit:15c3472
Author:Damien Neil
Committer:GitHub

protoc-gen-go: add more golden tests for imports (#538) Test importing in a variety of configurations: - Two files in the same Go and proto package. - Two files in the same Go package, but different proto packages. - Two files in different Go packages, but the same proto package. - Public imports. - Two files in the same package which each import a different Go package with the same name. (i.e., demonstrate whether rewrites of package names cross file boundaries.) - Imports which conflict with standard imports (e.g., "fmt").

Commit:bfa8400
Author:Tamir Duberstein
Committer:Damien Neil

travis: enforce generated code, add 1.x (#521) Update protoc to v3.5.1 while I'm here.

Commit:04869ad
Author:Damien Neil

[dev] protoc-gen-go: reorganize, fix testdata directory "make test" now compiles all the source files in testdata/ using the protoc-gen-go in the current working directory and compares the output to golden versions, "make regenerate" rebuilds the golden files. Add a go_package option to each proto source file. Put the sources for each package in the proper directory. Add a golden_test.go which arranges to compile each source file using the compiler in the working tree. This does not touch the content of any of the sources in testdata/ other than to add go_package options and fix up import paths. Change-Id: Iea5bef9bba626116b8ce5ea136a15f3cff4f5bcc

Commit:da3e237
Author:Chris Manghane
Committer:Chris Manghane

protoc-gen-go: indicate deprecated fields in documentation Tools in the Go ecosystem treat code documented with "Deprecated:" as special for purposes of warning users not to use them. When a file, message, field, enum, enum value, service, or method is marked as deprecated, the generator will emit "// Deprecated: Do not use." comments on all relevant exported Go package information related to the deprecated element. This is an outline of how deprecation of each element effects the generated proto: * file - a comment is added to the top of the generated proto. * message - a comment is added above its type definition. * field, enum, or enum value - a comment is added inline with the defintion. * field - an additional comment is added above the field Getter. * service - a comment is added above generated Client interface and New method. * service - a comment is added above generated Server interface and Registration method. * method - a comment is added above the generated method definition. Fixes #396.

Commit:2bc5431
Author:Herbie Ong
Committer:GitHub

jsonpb: change Marshal/Unmarshal to return error if any required field is not set (#472) Change Marshal/Unmarshal to return error if any required field is not set. For Unmarshal, this means JSON is either missing any required field or has required field set to null.

Commit:013f295
Author:Tamir Duberstein
Committer:Joe Tsai

Correct some mistakes (#316) * Regenerate * Correct some mistakes Most notable is the bug in (*proto.Properties).Parse, for which I've added a test. Found with honnef.co/go/tools/cmd/staticcheck. proto/properties.go:218:2: this value of s is never used (SA4006) proto/properties.go:329:5: ineffective break statement. Did you mean to break out of the outer loop? (SA4011) protoc-gen-go/generator/generator.go:1686:5: this value of obj is never used (SA4006)

Commit:8cc9e46
Author:Joe Tsai
Committer:Joe Tsai

Upstream internal Google protobuf changes Major changes: * New table-driven optimization for marshal, unmarshal, and merge * Unknown field preservation for Proto3 * Generated source-file annotation for Kythe * Various bug fixes

Commit:ae59567
Author:Joshua Humphries
Committer:Herbie Ong

update protos to 3.4.1 tag of google/protobuf repo (#428) * update protos from protoc 3.4.1 * make sure we match the v3.4.1 tag in google/protobuf

Commit:ab9f9a6
Author:Joshua Humphries
Committer:Herbie Ong

changed registered paths for WKT to use proto import path google/protobuf/... (#412) * build ptypes protos using proper import file path; remove redundant proto files * re-gen descriptor.pb.go * include copies of descriptor.proto and plugin.proto, too * keep copy of protos in repo

Commit:9f174c9
Author:Vladimir Varankin
Committer:Herbie Ong

Fix jsonpb to serialize NaN and Infinity as special strings (#242) Fix jsonpb to serialize NaN and Infinity properly. Fixes #231

Commit:7a211bc
Author:Eric Wang
Committer:Herbie Ong

Fix jsonpb to emit zero values for Map, Slice, Ptr when EmitDefaults=true When jsonpb.Marshaler.EmitDefaults is set to true, marshal zero values of the following types accordingly: Map to {} Slice to [] Ptr to null

Commit:157d9c5
Author:Ross Light

regenerate pb.go files with protobuf 3.3.0 Some schema changes, but mostly the codegen comment convention.

Commit:18c9bb3
Author:CH Albach
Committer:Herbie Ong

jsonpb: unmarshalling of Struct, ListValue, Value, Any and proto2 extensions; and marshalling of ListValue.

Commit:cb9b777
Author:lmilewski
Committer:Lukasz Milewski

Add a benchmark demonstrating lock contention when Marshaling/Unmarshaling maps. This benchmark is derived from a Google service which experienced poor performance when handling protos with maps. The current implementation of map decoding uses reflection. In particular reflect.New, reflect.NewAt, and reflect.(*Value).Addr all call reflect.(*rvalue).ptrTo. reflect.(*rvalue).ptrTo uses a cache protected by a mutex. Grabbing this lock is what causes the problem. reflect.(*rvalue).ptrTo also implements a fast path (which avoids critical sections) for certain types known to the compiler. Hopefully we can extend the compiler to generate descriptors for more types (https://golang.org/issue/17931) so that we can hit the fast path for all types needed for proto decoding. PiperOrigin-RevId: 139337589

Commit:5fb654a
Author:notcarl
Committer:Joe Tsai

Add Varint decoding benchmarks PiperOrigin-RevId: 135181742

Commit:f592bd2
Author:Ross Light

_conformance: generate proto

Commit:2c1988e
Author:Feng Xiao
Committer:Ross Light

Update Go tests for C++ JSON name change

Commit:2c2f726
Author:Bryan Mills
Committer:Ross Light

protoc-gen-go: Make proto3 scalar repeated fields packed by default (per the proto3 spec). This resolves #197.

Commit:18a29c0
Author:Ross Light

regenerate .pb.go

Commit:874264f
Author:Damien Neil
Committer:Damien Neil

proto: check for required fields when unmarshalling groups Change-Id: Icf8b82a07500ab226cf24b4c6aacc9a0a7476a59

Commit:af59feb
Author:Damien Neil
Committer:Damien Neil

jsonpb: sort numeric proto keys in numeric order When marshalling to JSON, sort numeric proto keys in numeric order per https://developers.google.com/protocol-buffers/docs/proto#maps. Change-Id: Iab5bdfbf599ce35e856ad4d0e503fd2ab1a9aacd

Commit:f6b4231
Author:matloob@google.com
Committer:matloob@google.com

proto: import change from Google. Add tests for merging a map field. When src contains a duplicate key, its value message replaces (not merges with) the value message in dst.

Commit:8616e8e
Author:Ross Light

ptypes: regen and remove transforms from regen.sh

Commit:bf531ff
Author:David Symonds
Committer:David Symonds

jsonpb: Marshal Any according to the spec. Unmarshaling Any is a TODO. Fixes #170.

Commit:f0a097d
Author:David Symonds
Committer:David Symonds

jsonpb: Fix handling of repeated enums. Enums used in maps is still broken, but commented-out test data is now there, together with TODOs. Fixes #164.

Commit:78550bb
Author:Bryan Mills
Committer:David Symonds

Improve error message when text unmarshaling a nested message with a required field. Signed-off-by: David Symonds <dsymonds@golang.org>

Commit:62e4364
Author:David Symonds
Committer:David Symonds

jsonpb: Accept both camelCase and orig_name as field names for oneof fields. Fixes #148.

Commit:750c6bd
Author:David Symonds
Committer:David Symonds

Generate the new go_package options for the WKTs. This is getting upstreamed; for now, do it locally to ease construction.

Commit:1cc4d6f
Author:Lev Shamardin
Committer:David Symonds

Support for google.protobuf.Any expansion in text marshaling and unmarshaling. Signed-off-by: David Symonds <dsymonds@golang.org>

Commit:552c7b9
Author:David Symonds
Committer:David Symonds

jsonpb: Handle Struct and NullValue WKTs.

Commit:c6184d3
Author:David Symonds
Committer:David Symonds

jsonpb: Format and parse the WKTs in wrappers.proto. Per the spec, they are meant to use the same representation in JSON as the wrapped primitive type. Fortunately for us, that is trivial to implement.

Commit:553c764
Author:David Symonds
Committer:David Symonds

Generate XXX_WellKnownType method for recognised well-known types. Just Duration and Timestamp for now. Make jsonpb recognise them and format/parse according to the spec.

Commit:1270911
Author:David Symonds
Committer:David Symonds

Rearrange the well-known types package layout and API: - Rename `types` to `ptypes`. - Rename `DurationFromProto` to `Duration`. - Unexport `ValidateDuration`. Sorry for the breakage. This should be the final location of everything.

Commit:0dfe8f3
Author:David Symonds

Add more well-known types: Struct, Timestamp and Wrappers. Updates #50.

Commit:8ea33d2
Author:David Symonds
Committer:David Symonds

Add well-known types. This introduces supported Go packages for each well-known type, and a placeholder support package for interacting with them. This commit adds Any, Duration and Empty; more types will follow. Updates #50.

Commit:0879490
Author:Damien Neil
Committer:David Symonds

Generate sizer functions for oneofs. This improves oneof sizing performance by ~9x. func BenchmarkSizeTrivial(b *testing.B) { benchmarkSize(b, &MyMessage{Count: Int32(0)}) } func BenchmarkSizeOneof(b *testing.B) { benchmarkSize(b, &Communique{Union: &Communique_Number{0}}) } Without this change: BenchmarkSizeTrivial-12 5000000 355 ns/op BenchmarkSizeOneof-12 500000 2754 ns/op With this change: BenchmarkSizeTrivial-12 5000000 336 ns/op BenchmarkSizeOneof-12 5000000 306 ns/op Signed-off-by: David Symonds <dsymonds@golang.org>

Commit:7c1e7ed
Author:Erik McClenney
Committer:David Symonds

Fix unmarshaling code to properly handle multiple instances of the same extension appearing in the wire format. Prior to this change, multiple custom options would result in all but the first being discarded when processed using the proto.GetExtension() facilities. Signed-off-by: David Symonds <dsymonds@golang.org>

Commit:f9dd693
Author:Juraj Stacho
Committer:David Symonds

jsonpb: Implementing marshaling of proto2 extensions. Signed-off-by: David Symonds <dsymonds@golang.org>

Commit:5baca1b
Author:David Symonds
Committer:David Symonds

Forward oneof marshal/unmarshal funcs through public imports. The collision of these two protocol buffer features does not work well in Go; the best we can easily do is to handle the wire format. It'll operate poorly when used with the text or JSON formats.

Commit:8081512
Author:Andrew Braunstein
Committer:David Symonds

Ensure all field and method names are unique. This change forces the compiler to pick unique names when generating getters. If a name collision is found when generating a getter, it follows the same convention as fields do and appends an "_" to the end of the method name. Signed-off-by: David Symonds <dsymonds@golang.org>

Commit:535a104
Author:David Symonds
Committer:David Symonds

Fix size of oneof fields when they are set to their zero value. We use the proto3 sizers for oneof fields (because they don't have a pointer in the wrapper struct), but they are always encoded when set, so we should not skip their zero value. Fixes #74.

Commit:59b73b3
Author:David Symonds
Committer:David Symonds

Implement oneof support. This includes the code generation changes, and the infrastructure to wire it up to the encode/decode machinery. The overall API changes are these: - oneofs in a message are replaced by a single interface field - each field in a oneof gets a distinguished type that satisfies the corresponding interface - a type switch may be used to distinguish between oneof fields Fixes #29.

Commit:67cbcad
Author:Buck Clay
Committer:David Symonds

jsonpb: New package. This is the official JSON support for protocol buffers, matching the standard format for proto3.

Commit:95681cb
Author:David Symonds
Committer:David Symonds

Remove "optional" keyword in proto3 test file. protoc will soon be rejecting this keyword in proto3 files.

Commit:c8ba115
Author:David Symonds
Committer:David Symonds

Add support for default values in proto extensions.

Commit:a8323e2
Author:David Symonds
Committer:David Symonds

Fix Size for maps. This was terribly broken, but we got lucky for small map entries. The old code was trying to compute the size of the tag codes for the key and value, but that's the responsibility of the sizer for the particular key and value. What size_new_map needs to account for is the length of the tag code and length varint of the map entry itself. Fixes #21.

Commit:889ae49
Author:David Symonds

Fix encoding and sizing of empty byte slices in proto3 maps. Empty byte slices were being skipped, since that's the correct behaviour when it is a standalone bytes field, but it's the wrong behaviour when it is the value of a map field, which should always have its key and value encoded. Fixes #20.

Commit:de8c523
Author:David Symonds

Implement SetDefaults for maps. Skip proto3 scalar fields instead of panicking.

Commit:a8de284
Author:David Symonds

Use full import paths for test protos.

Commit:c22ae3c
Author:David Symonds
Committer:David Symonds

Add gRPC code generation.

Commit:425d36a
Author:David Symonds

Update comments, package declarations and syntax statements.

Commit:3ea3e05
Author:David Symonds
Committer:David Symonds

Support map<k,v> protocol buffer fields.

Commit:abd3b41
Author:David Symonds
Committer:David Symonds

Support proto3.

Commit:558f13f
Author:David Symonds

Update URLs and import paths to new GitHub home.

Commit:bebcf5d
Author:David Symonds

goprotobuf: Add method to extending message to get list of messages extended. LGTM=gmlewis R=gmlewis CC=golang-codereviews https://codereview.appspot.com/159790043

Commit:7e81098
Author:David Symonds

goprotobuf: Fix handling of empty string defaults for 'string' and 'bytes' fields. This is a bit of an edge case. All other valid defaults appear as non-empty strings, but we need to distinguish [default=""] for string/bytes to uphold the SetDefaults contract. LGTM=djd R=djd CC=golang-codereviews https://codereview.appspot.com/125100044

Commit:f054e84
Author:David Symonds

goprotobuf: Split encoding of int32 and uint32 fields. int32 needs special handling; negative values need to be sign-extended, so need to be converted from uint32 back to int32 before converting to uint64 for the varint encoding step (yielding 10 bytes). uint32 is simpler and stays as just encoding the bit pattern, and thus never takes more than 5 bytes. This permits upgrading int32 fields to int64, and matches C++. LGTM=nigeltao R=nigeltao CC=golang-codereviews https://codereview.appspot.com/114190043

Commit:47fc4db
Author:David Symonds

goprotobuf: Required extensions don't make sense. LGTM=nigeltao R=nigeltao CC=golang-codereviews https://codereview.appspot.com/101370050

Commit:1cb9013
Author:David Symonds

goprotobuf: Make the default default of an enum field be the value of the first enum value, not zero. This makes Go consistent with C++/Java/Python. Fixes #43. R=r CC=golang-dev https://codereview.appspot.com/13501049

Commit:58a7583
Author:David Symonds

goprotobuf: Fix handling of publicly imported enum types. R=r CC=golang-dev https://codereview.appspot.com/12436045

Commit:5292590
Author:David Symonds

goprotobuf: Present comments in .proto files in the generated .pb.go. This doesn't use every comment, but just the ones that I thought would be most useful to someone reading the generated code, namely those attached to these things: - messages - message fields - enums - enum values R=r CC=golang-dev https://codereview.appspot.com/11889044

Commit:5bbe4ae
Author:David Symonds

goprotobuf: Switch to using protobuf-2.5.0 as the baseline. Regenerating descriptor.pb.go also lays the path for using SourceCodeInfo in the code generator. R=r CC=golang-dev https://codereview.appspot.com/11893043

Commit:472e259
Author:David Symonds

goprotobuf: Fix SetDefaults to recur into repeated submessages. R=r CC=golang-dev https://codereview.appspot.com/11255043

Commit:9c8d847
Author:David Symonds

goprotobuf: Fix Size accounting of packed fields. Fixes #40. R=crawshaw CC=golang-dev https://codereview.appspot.com/10477043

Commit:6677c3e
Author:David Symonds

goprotobuf: Fix Size for groups. The previous code did not account for groups at all; the test data was getting lucky. Fixes #38. R=r CC=golang-dev https://codereview.appspot.com/10147043

Commit:0c1184e
Author:David Symonds

goprotobuf: Make MessageSet marshaling deterministic. R=r CC=golang-dev https://codereview.appspot.com/10119045