Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge remote-tracking branch 'origin/dev' into master #591

Merged
merged 69 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
8cc9e46
Upstream internal Google protobuf changes
dsnet Nov 8, 2017
3ffccb4
Remove unused code (#313)
tamird Nov 20, 2017
013f295
Correct some mistakes (#316)
tamird Nov 20, 2017
1ec9e17
Fix uint64->int overflow in table unmarshal (#461)
neild Nov 29, 2017
5c7dd33
Simplify code (#314)
tamird Dec 6, 2017
49f2ba7
jsonpb: check for nil in Marshal and return error to avoid panic. (#469)
cybrcodr Dec 11, 2017
575152e
Cleanup comments and whitespace (#471)
dsnet Dec 12, 2017
2bc5431
jsonpb: change Marshal/Unmarshal to return error if any required fiel…
cybrcodr Jan 5, 2018
572071c
Use fmt.Errorf instead of errors.New (#481)
dsnet Jan 11, 2018
7d76aa1
Remove raw interface (#482)
dsnet Jan 12, 2018
2bd7280
protoc-gen-go: format interfaces for gofmt 1.9 and 1.10 (#486)
neild Jan 18, 2018
5f34c20
proto: expose accessors for raw value of extensions (#483)
jhump Jan 19, 2018
ac606b1
jsonpb: fix handling of illegal and negative nanoseconds (#492)
dfawley Jan 23, 2018
f9bf3fb
jsonpb: change Marshal to trim timestamp/duration to 0 fractional dig…
ochen Jan 24, 2018
10c2d9d
proto: add logic to handle legacy message (#496)
dsnet Jan 25, 2018
3525335
proto: reject invalid UTF-8 in strings (#499)
dsnet Jan 26, 2018
b409cc5
proto: remove Proto3UnknownFields flag (#497)
dsnet Jan 27, 2018
57af863
proto: robustify tests that compare error messages (#500)
dsnet Jan 29, 2018
97a81c9
proto: fix govet failures in Go 1.10 (#505)
Feb 1, 2018
9a84eb8
proto: support purego build tag
dsnet Feb 2, 2018
da3e237
protoc-gen-go: indicate deprecated fields in documentation
Feb 2, 2018
42d4f47
jsonpb: skip unexported or non-protobuf fields (#510)
jhump Feb 3, 2018
cb908bf
Merge pull request #506 from paranoiacblack/deprecated-fields
Feb 3, 2018
f4b403d
all: update to protoc v3.5.1 for testing
dsnet Feb 7, 2018
e6af52b
proto: treat bad wire types as unknown fields (#511)
dsnet Feb 7, 2018
04869ad
[dev] protoc-gen-go: reorganize, fix testdata directory
neild Feb 20, 2018
8cbe6f4
[dev] Add 'all' targets back to Makefiles.
neild Feb 20, 2018
025a21d
[dev] multi/multi*.pb.go: add these files and remove them from .gitig…
neild Feb 20, 2018
f7e61e1
[dev] Set plugins=grpc when generating testdata protos.
neild Feb 21, 2018
055d7b0
[dev] remove spurious comment
neild Feb 21, 2018
b322e49
Merge pull request #520 from neild/dev.alias
neild Feb 21, 2018
2c2f6de
Fix top-level Makefile to descend into protoc-gen-go. (#523)
neild Feb 21, 2018
bfa8400
travis: enforce generated code, add 1.x (#521)
tamird Feb 21, 2018
efae459
no more generated package doc (#528)
jhump Feb 22, 2018
649500c
proto: avoid pointer arithmetic with invalidField (#529)
dsnet Feb 22, 2018
1021ee9
protoc-gen-go: include canonical import comment (#534)
neild Feb 26, 2018
2ef4baf
protoc-gen-go: remove relative import in main_test.go (#535)
neild Feb 27, 2018
60f8421
Rename generated Marshal and Unmarshal protobuf method (#536)
dsnet Feb 28, 2018
15c3472
protoc-gen-go: add more golden tests for imports (#538)
neild Mar 1, 2018
3194ec9
protoc-gen-go: regenerate golden tests (#540)
neild Mar 1, 2018
1c9f675
README: change minimum required Go version Go 1.6 (#541)
neild Mar 1, 2018
f4733c7
protoc-gen-go: don't depend on input file ordering (#542)
neild Mar 1, 2018
a198716
protoc-gen-go: add test for various generation params (#539)
neild Mar 2, 2018
9d4962b
protoc-gen-go: handle package import names per-file (#543)
neild Mar 3, 2018
6fb8a6f
protoc-gen-go: add paths=source_relative option (#544)
neild Mar 6, 2018
2b3479d
protoc-gen-go: fix test (#545)
neild Mar 7, 2018
251359b
protobuf: Delete makefiles, regenerate protos consistently (#546)
neild Mar 7, 2018
3dc8a89
protoc-gen-go: use standard library context (requires Go1.9) (#548)
dsnet Mar 8, 2018
12a586e
golden_test: normalize path separators for Windows (#550)
Mar 9, 2018
b244a78
protoc-gen-go: don't generate blank // import comment (#554)
neild Mar 12, 2018
d0dc0de
Reduce a bunch of generated code in oneof sizers. (#557)
dsymonds Mar 13, 2018
80c8f76
protoc-gen-go: fix generation of public imports (#549)
neild Mar 13, 2018
ab964bf
conformance: clean up, fix conformance tests (#552)
neild Mar 13, 2018
e0ed903
descriptor: fix example name (#559)
dsnet Mar 13, 2018
2cbfb78
conformance: remove useless variable declaration (#558)
dsnet Mar 13, 2018
397ff90
protoc-gen-go: use keyed ExtensionRange literals (#560)
dsnet Mar 14, 2018
b028a76
proto: ignore unknown fields in map entries (#561)
dsnet Mar 14, 2018
9c8fb7a
protoc-gen-go: Don't rely on local package name for mset name hack. (…
neild Mar 15, 2018
91cccdb
proto: do not allow unknown fields to satisfy required field bit (#565)
dsnet Mar 28, 2018
06c268a
protoc-gen-go: revert some API changes (#577)
neild Mar 30, 2018
d3afd40
Configure Travis to test Go1.6 (again) (#571)
dsnet Mar 30, 2018
3b4abe1
protoc-gen-go: fix up generation of package names (#576)
neild Apr 2, 2018
9bb8760
protoc-gen-go: fix generation of proxy getters for distant types (#563)
neild Apr 3, 2018
6fb5325
Implement "import public" using type aliases. (#583)
neild Apr 13, 2018
bf2da82
Revert "protoc-gen-go: use standard library context (requires Go1.9) …
dfawley Apr 13, 2018
d167f5c
proto: remove unused writeRaw function (#585)
tamird Apr 16, 2018
fae8ec6
proto: amortize cost of growing a Buffer (#584)
rhysh Apr 17, 2018
acbe2df
protoc-gen-go: fix release tag in golden_test (#590)
neild Apr 30, 2018
8db9ce6
Merge remote-tracking branch 'origin/dev' into master
dsnet Apr 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ core
_obj
_test
_testmain.go
protoc-gen-go/testdata/multi/*.pb.go
_conformance/_conformance

# Conformance test output and transient files.
conformance/failing_tests.txt
24 changes: 18 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@ sudo: false
language: go
go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.x

install:
- go get -v -d -t github.com/golang/protobuf/...
- curl -L https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip -o /tmp/protoc.zip
- unzip /tmp/protoc.zip -d $HOME/protoc
- curl -L https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip -o /tmp/protoc.zip
- unzip /tmp/protoc.zip -d "$HOME"/protoc
- mkdir -p "$HOME"/src && ln -s "$HOME"/protoc "$HOME"/src/protobuf

env:
- PATH=$HOME/protoc/bin:$PATH

script:
- make all test
- make all
- make regenerate
# TODO(tamird): When https://github.com/travis-ci/gimme/pull/130 is
# released, make this look for "1.x".
- if [[ "$TRAVIS_GO_VERSION" == 1.10* ]]; then
if [[ "$(git status --porcelain 2>&1)" != "" ]]; then
git status >&2;
git diff -a >&2;
exit 1;
fi;
echo "git status is clean.";
fi;
- make test
40 changes: 0 additions & 40 deletions Make.protobuf

This file was deleted.

15 changes: 4 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


all: install

install:
go install ./proto ./jsonpb ./ptypes
go install ./protoc-gen-go
go install ./proto ./jsonpb ./ptypes ./protoc-gen-go

test:
go test ./proto ./jsonpb ./ptypes
make -C protoc-gen-go/testdata test
go test ./... ./protoc-gen-go/testdata
make -C conformance test

clean:
go clean ./...
Expand All @@ -47,9 +45,4 @@ nuke:
go clean -i ./...

regenerate:
make -C protoc-gen-go/descriptor regenerate
make -C protoc-gen-go/plugin regenerate
make -C protoc-gen-go/testdata regenerate
make -C proto/testdata regenerate
make -C jsonpb/jsonpb_test_proto regenerate
make -C _conformance regenerate
./regenerate.sh
65 changes: 52 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Google's data interchange format.
Copyright 2010 The Go Authors.
https://github.com/golang/protobuf

This package and the code it generates requires at least Go 1.4.
This package and the code it generates requires at least Go 1.6.

This software implements Go bindings for protocol buffers. For
information about protocol buffers themselves, see
Expand Down Expand Up @@ -56,13 +56,49 @@ parameter set to the directory you want to output the Go code to.
The generated files will be suffixed .pb.go. See the Test code below
for an example using such a file.

## Packages and input paths ##

The protocol buffer language has a concept of "packages" which does not
correspond well to the Go notion of packages. In generated Go code,
each source `.proto` file is associated with a single Go package. The
name and import path for this package is specified with the `go_package`
proto option:

option go_package = "github.com/golang/protobuf/ptypes/any";

The protocol buffer compiler will attempt to derive a package name and
import path if a `go_package` option is not present, but it is
best to always specify one explicitly.

There is a one-to-one relationship between source `.proto` files and
generated `.pb.go` files, but any number of `.pb.go` files may be
contained in the same Go package.

The output name of a generated file is produced by replacing the
`.proto` suffix with `.pb.go` (e.g., `foo.proto` produces `foo.pb.go`).
However, the output directory is selected in one of two ways. Let
us say we have `inputs/x.proto` with a `go_package` option of
`github.com/golang/protobuf/p`. The corresponding output file may
be:

- Relative to the import path:

protoc --go_out=. inputs/x.proto
# writes ./github.com/golang/protobuf/p/x.pb.go

(This can work well with `--go_out=$GOPATH`.)

- Relative to the input file:

protoc --go_out=paths=source_relative:. inputs/x.proto
# generate ./inputs/x.pb.go

## Generated code ##

The package comment for the proto library contains text describing
the interface provided in Go for protocol buffers. Here is an edited
version.

==========

The proto package converts data structures to and from the
wire format of protocol buffers. It works in concert with the
Go source code generated for .proto files by the protocol compiler.
Expand Down Expand Up @@ -114,9 +150,9 @@ Consider file test.proto, containing
```proto
syntax = "proto2";
package example;
enum FOO { X = 17; };
message Test {
required string label = 1;
optional int32 type = 2 [default=77];
Expand Down Expand Up @@ -170,22 +206,25 @@ To create and play with a Test object from the example package,
To pass extra parameters to the plugin, use a comma-separated
parameter list separated from the output directory by a colon:


protoc --go_out=plugins=grpc,import_path=mypackage:. *.proto


- `import_prefix=xxx` - a prefix that is added onto the beginning of
all imports. Useful for things like generating protos in a
subdirectory, or regenerating vendored protobufs in-place.
- `import_path=foo/bar` - used as the package if no input files
declare `go_package`. If it contains slashes, everything up to the
rightmost slash is ignored.
- `paths=(import | source_relative)` - specifies how the paths of
generated files are structured. See the "Packages and imports paths"
section above. The default is `import`.
- `plugins=plugin1+plugin2` - specifies the list of sub-plugins to
load. The only plugin in this repo is `grpc`.
- `Mfoo/bar.proto=quux/shme` - declares that foo/bar.proto is
associated with Go package quux/shme. This is subject to the
import_prefix parameter.

The following parameters are deprecated and should not be used:

- `import_prefix=xxx` - a prefix that is added onto the beginning of
all imports.
- `import_path=foo/bar` - used as the package if no input files
declare `go_package`. If it contains slashes, everything up to the
rightmost slash is ignored.

## gRPC Support ##

If a proto file specifies RPC services, protoc-gen-go can be instructed to
Expand Down
20 changes: 18 additions & 2 deletions _conformance/Makefile → conformance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,21 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

regenerate:
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
PROTOBUF_ROOT=$(HOME)/src/protobuf

all:
@echo To run the tests in this directory, acquire the main protobuf
@echo distribution from:
@echo
@echo ' https://github.com/google/protobuf'
@echo
@echo Build the test runner with:
@echo
@echo ' cd conformance && make conformance-test-runner'
@echo
@echo And run the tests in this directory with:
@echo
@echo ' make test PROTOBUF_ROOT=<protobuf distribution>'

test:
./test.sh $(PROTOBUF_ROOT)
9 changes: 1 addition & 8 deletions _conformance/conformance.go → conformance/conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"io"
"os"

pb "github.com/golang/protobuf/_conformance/conformance_proto"
pb "github.com/golang/protobuf/conformance/internal/conformance_proto"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
Expand Down Expand Up @@ -101,13 +101,6 @@ func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse {
err = proto.Unmarshal(p.ProtobufPayload, &msg)
case *pb.ConformanceRequest_JsonPayload:
err = jsonpb.UnmarshalString(p.JsonPayload, &msg)
if err != nil && err.Error() == "unmarshaling Any not supported yet" {
return &pb.ConformanceResponse{
Result: &pb.ConformanceResponse_Skipped{
Skipped: err.Error(),
},
}
}
default:
return &pb.ConformanceResponse{
Result: &pb.ConformanceResponse_RuntimeError{
Expand Down
4 changes: 4 additions & 0 deletions conformance/conformance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

cd $(dirname $0)
exec go run conformance.go $*
61 changes: 61 additions & 0 deletions conformance/failure_list_go.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is the list of conformance tests that are known ot fail right now.
# TODO: These should be fixed.

DurationProtoInputTooLarge.JsonOutput
DurationProtoInputTooSmall.JsonOutput
FieldMaskNumbersDontRoundTrip.JsonOutput
FieldMaskPathsDontRoundTrip.JsonOutput
FieldMaskTooManyUnderscore.JsonOutput
JsonInput.AnyWithFieldMask.JsonOutput
JsonInput.AnyWithFieldMask.ProtobufOutput
JsonInput.DoubleFieldQuotedValue.JsonOutput
JsonInput.DoubleFieldQuotedValue.ProtobufOutput
JsonInput.DurationHas3FractionalDigits.Validator
JsonInput.DurationHas6FractionalDigits.Validator
JsonInput.DurationHas9FractionalDigits.Validator
JsonInput.DurationHasZeroFractionalDigit.Validator
JsonInput.DurationMaxValue.JsonOutput
JsonInput.DurationMaxValue.ProtobufOutput
JsonInput.DurationMinValue.JsonOutput
JsonInput.DurationMinValue.ProtobufOutput
JsonInput.EnumFieldUnknownValue.Validator
JsonInput.FieldMask.JsonOutput
JsonInput.FieldMask.ProtobufOutput
JsonInput.FieldNameInLowerCamelCase.Validator
JsonInput.FieldNameWithMixedCases.JsonOutput
JsonInput.FieldNameWithMixedCases.ProtobufOutput
JsonInput.FieldNameWithMixedCases.Validator
JsonInput.FieldNameWithNumbers.Validator
JsonInput.FloatFieldQuotedValue.JsonOutput
JsonInput.FloatFieldQuotedValue.ProtobufOutput
JsonInput.Int32FieldExponentialFormat.JsonOutput
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
JsonInput.Int32FieldMaxFloatValue.JsonOutput
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
JsonInput.Int32FieldMinFloatValue.JsonOutput
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
JsonInput.Int32FieldStringValue.JsonOutput
JsonInput.Int32FieldStringValue.ProtobufOutput
JsonInput.Int32FieldStringValueEscaped.JsonOutput
JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
JsonInput.Int64FieldBeString.Validator
JsonInput.MapFieldValueIsNull
JsonInput.OneofFieldDuplicate
JsonInput.RepeatedFieldMessageElementIsNull
JsonInput.RepeatedFieldPrimitiveElementIsNull
JsonInput.StringFieldSurrogateInWrongOrder
JsonInput.StringFieldUnpairedHighSurrogate
JsonInput.StringFieldUnpairedLowSurrogate
JsonInput.TimestampHas3FractionalDigits.Validator
JsonInput.TimestampHas6FractionalDigits.Validator
JsonInput.TimestampHas9FractionalDigits.Validator
JsonInput.TimestampHasZeroFractionalDigit.Validator
JsonInput.TimestampJsonInputTooSmall
JsonInput.TimestampZeroNormalized.Validator
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
JsonInput.Uint64FieldBeString.Validator
TimestampProtoInputTooLarge.JsonOutput
TimestampProtoInputTooSmall.JsonOutput
Loading