Skip to content

Commit b4deda0

Browse files
authored
Merge pull request #591 from golang/master-merge
Merge remote-tracking branch 'origin/dev' into master
2 parents e09c5db + 8db9ce6 commit b4deda0

File tree

133 files changed

+21386
-11021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+21386
-11021
lines changed

Diff for: .gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ core
1212
_obj
1313
_test
1414
_testmain.go
15-
protoc-gen-go/testdata/multi/*.pb.go
16-
_conformance/_conformance
15+
16+
# Conformance test output and transient files.
17+
conformance/failing_tests.txt

Diff for: .travis.yml

+18-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@ sudo: false
22
language: go
33
go:
44
- 1.6.x
5-
- 1.7.x
6-
- 1.8.x
7-
- 1.9.x
5+
- 1.10.x
6+
- 1.x
87

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

1414
env:
1515
- PATH=$HOME/protoc/bin:$PATH
1616

1717
script:
18-
- make all test
18+
- make all
19+
- make regenerate
20+
# TODO(tamird): When https://github.com/travis-ci/gimme/pull/130 is
21+
# released, make this look for "1.x".
22+
- if [[ "$TRAVIS_GO_VERSION" == 1.10* ]]; then
23+
if [[ "$(git status --porcelain 2>&1)" != "" ]]; then
24+
git status >&2;
25+
git diff -a >&2;
26+
exit 1;
27+
fi;
28+
echo "git status is clean.";
29+
fi;
30+
- make test

Diff for: Make.protobuf

-40
This file was deleted.

Diff for: Makefile

+4-11
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@
2929
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3030
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131

32-
3332
all: install
3433

3534
install:
36-
go install ./proto ./jsonpb ./ptypes
37-
go install ./protoc-gen-go
35+
go install ./proto ./jsonpb ./ptypes ./protoc-gen-go
3836

3937
test:
40-
go test ./proto ./jsonpb ./ptypes
41-
make -C protoc-gen-go/testdata test
38+
go test ./... ./protoc-gen-go/testdata
39+
make -C conformance test
4240

4341
clean:
4442
go clean ./...
@@ -47,9 +45,4 @@ nuke:
4745
go clean -i ./...
4846

4947
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
48+
./regenerate.sh

Diff for: README.md

+52-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Google's data interchange format.
77
Copyright 2010 The Go Authors.
88
https://github.com/golang/protobuf
99

10-
This package and the code it generates requires at least Go 1.4.
10+
This package and the code it generates requires at least Go 1.6.
1111

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

59+
## Packages and input paths ##
60+
61+
The protocol buffer language has a concept of "packages" which does not
62+
correspond well to the Go notion of packages. In generated Go code,
63+
each source `.proto` file is associated with a single Go package. The
64+
name and import path for this package is specified with the `go_package`
65+
proto option:
66+
67+
option go_package = "github.com/golang/protobuf/ptypes/any";
68+
69+
The protocol buffer compiler will attempt to derive a package name and
70+
import path if a `go_package` option is not present, but it is
71+
best to always specify one explicitly.
72+
73+
There is a one-to-one relationship between source `.proto` files and
74+
generated `.pb.go` files, but any number of `.pb.go` files may be
75+
contained in the same Go package.
76+
77+
The output name of a generated file is produced by replacing the
78+
`.proto` suffix with `.pb.go` (e.g., `foo.proto` produces `foo.pb.go`).
79+
However, the output directory is selected in one of two ways. Let
80+
us say we have `inputs/x.proto` with a `go_package` option of
81+
`github.com/golang/protobuf/p`. The corresponding output file may
82+
be:
83+
84+
- Relative to the import path:
85+
86+
protoc --go_out=. inputs/x.proto
87+
# writes ./github.com/golang/protobuf/p/x.pb.go
88+
89+
(This can work well with `--go_out=$GOPATH`.)
90+
91+
- Relative to the input file:
92+
93+
protoc --go_out=paths=source_relative:. inputs/x.proto
94+
# generate ./inputs/x.pb.go
95+
96+
## Generated code ##
5997

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

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

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

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

220+
The following parameters are deprecated and should not be used:
221+
222+
- `import_prefix=xxx` - a prefix that is added onto the beginning of
223+
all imports.
224+
- `import_path=foo/bar` - used as the package if no input files
225+
declare `go_package`. If it contains slashes, everything up to the
226+
rightmost slash is ignored.
227+
189228
## gRPC Support ##
190229

191230
If a proto file specifies RPC services, protoc-gen-go can be instructed to

Diff for: _conformance/Makefile renamed to conformance/Makefile

+18-2
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,21 @@
2929
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3030
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131

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
32+
PROTOBUF_ROOT=$(HOME)/src/protobuf
33+
34+
all:
35+
@echo To run the tests in this directory, acquire the main protobuf
36+
@echo distribution from:
37+
@echo
38+
@echo ' https://github.com/google/protobuf'
39+
@echo
40+
@echo Build the test runner with:
41+
@echo
42+
@echo ' cd conformance && make conformance-test-runner'
43+
@echo
44+
@echo And run the tests in this directory with:
45+
@echo
46+
@echo ' make test PROTOBUF_ROOT=<protobuf distribution>'
47+
48+
test:
49+
./test.sh $(PROTOBUF_ROOT)

Diff for: _conformance/conformance.go renamed to conformance/conformance.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
"io"
4040
"os"
4141

42-
pb "github.com/golang/protobuf/_conformance/conformance_proto"
42+
pb "github.com/golang/protobuf/conformance/internal/conformance_proto"
4343
"github.com/golang/protobuf/jsonpb"
4444
"github.com/golang/protobuf/proto"
4545
)
@@ -101,13 +101,6 @@ func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse {
101101
err = proto.Unmarshal(p.ProtobufPayload, &msg)
102102
case *pb.ConformanceRequest_JsonPayload:
103103
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-
}
111104
default:
112105
return &pb.ConformanceResponse{
113106
Result: &pb.ConformanceResponse_RuntimeError{

Diff for: conformance/conformance.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
cd $(dirname $0)
4+
exec go run conformance.go $*

Diff for: conformance/failure_list_go.txt

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This is the list of conformance tests that are known ot fail right now.
2+
# TODO: These should be fixed.
3+
4+
DurationProtoInputTooLarge.JsonOutput
5+
DurationProtoInputTooSmall.JsonOutput
6+
FieldMaskNumbersDontRoundTrip.JsonOutput
7+
FieldMaskPathsDontRoundTrip.JsonOutput
8+
FieldMaskTooManyUnderscore.JsonOutput
9+
JsonInput.AnyWithFieldMask.JsonOutput
10+
JsonInput.AnyWithFieldMask.ProtobufOutput
11+
JsonInput.DoubleFieldQuotedValue.JsonOutput
12+
JsonInput.DoubleFieldQuotedValue.ProtobufOutput
13+
JsonInput.DurationHas3FractionalDigits.Validator
14+
JsonInput.DurationHas6FractionalDigits.Validator
15+
JsonInput.DurationHas9FractionalDigits.Validator
16+
JsonInput.DurationHasZeroFractionalDigit.Validator
17+
JsonInput.DurationMaxValue.JsonOutput
18+
JsonInput.DurationMaxValue.ProtobufOutput
19+
JsonInput.DurationMinValue.JsonOutput
20+
JsonInput.DurationMinValue.ProtobufOutput
21+
JsonInput.EnumFieldUnknownValue.Validator
22+
JsonInput.FieldMask.JsonOutput
23+
JsonInput.FieldMask.ProtobufOutput
24+
JsonInput.FieldNameInLowerCamelCase.Validator
25+
JsonInput.FieldNameWithMixedCases.JsonOutput
26+
JsonInput.FieldNameWithMixedCases.ProtobufOutput
27+
JsonInput.FieldNameWithMixedCases.Validator
28+
JsonInput.FieldNameWithNumbers.Validator
29+
JsonInput.FloatFieldQuotedValue.JsonOutput
30+
JsonInput.FloatFieldQuotedValue.ProtobufOutput
31+
JsonInput.Int32FieldExponentialFormat.JsonOutput
32+
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
33+
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
34+
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
35+
JsonInput.Int32FieldMaxFloatValue.JsonOutput
36+
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
37+
JsonInput.Int32FieldMinFloatValue.JsonOutput
38+
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
39+
JsonInput.Int32FieldStringValue.JsonOutput
40+
JsonInput.Int32FieldStringValue.ProtobufOutput
41+
JsonInput.Int32FieldStringValueEscaped.JsonOutput
42+
JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
43+
JsonInput.Int64FieldBeString.Validator
44+
JsonInput.MapFieldValueIsNull
45+
JsonInput.OneofFieldDuplicate
46+
JsonInput.RepeatedFieldMessageElementIsNull
47+
JsonInput.RepeatedFieldPrimitiveElementIsNull
48+
JsonInput.StringFieldSurrogateInWrongOrder
49+
JsonInput.StringFieldUnpairedHighSurrogate
50+
JsonInput.StringFieldUnpairedLowSurrogate
51+
JsonInput.TimestampHas3FractionalDigits.Validator
52+
JsonInput.TimestampHas6FractionalDigits.Validator
53+
JsonInput.TimestampHas9FractionalDigits.Validator
54+
JsonInput.TimestampHasZeroFractionalDigit.Validator
55+
JsonInput.TimestampJsonInputTooSmall
56+
JsonInput.TimestampZeroNormalized.Validator
57+
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
58+
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
59+
JsonInput.Uint64FieldBeString.Validator
60+
TimestampProtoInputTooLarge.JsonOutput
61+
TimestampProtoInputTooSmall.JsonOutput

0 commit comments

Comments
 (0)