1096 Commits

Author SHA1 Message Date
Lasse Folger
fe5bc54041 all: start v1.29.0-devel
Change-Id: I543d164519c1f8a095f9d8975213b182b3067f20
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/474436
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2023-03-08 15:36:41 +00:00
Lasse Folger
d3c9826520 all: release v1.29.0
Change-Id: Ieb49f0086eddc141eb0d13c749474803d22354d4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/474435
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2023-03-08 15:33:56 +00:00
googleberg
eba8b0975f cmd/protoc-gen-go: support protobuf retention feature
This change strips out all descriptor option fields marked with [retention = RETENTION_SOURCE] before writing the FileDescriptor to the generated go code bindings.

Change-Id: Ie624d9d4b4f211a256661d80a04199ae8401662b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/472696
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2023-03-07 09:24:00 +00:00
Josh Humphries
fcf5f6cb72 encoding/prototext: allow whitespace and comments between minus sign and number in negative numeric literal
The text format specification[1] indicates that whitespace and comments
may appear after a minus sign and before the subsequent numeric component
in negative number literals. But the Go implementation does not allow
this.

This brings the Go implementation info conformance with this aspect.

Fixes golang/protobuf#1526

[1] https://protobuf.dev/reference/protobuf/textformat-spec/#parsing

Change-Id: I3996c89ee9d37cf2b7502fc6736d6e2ed6dbcf43
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/473015
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2023-03-06 07:33:04 +00:00
Josh Humphries
bc1253ad37 types/descriptorpb: regenerate using latest protobuf v22.0 release
This updates all generated code to match the contents of the latest
v22.0 release of Protobuf.

This involved a couple of changes to the script that does the sync'ing:
  1. The new Protobuf version no longer includes autoconf configuration
     and instead requires using bazel to build things.
  2. The new Protobuf release does not have an artifact named
     "protobuf-all-${VERSION}.tar.gz", but the one named
     "protobuf-${VERSION}.tar.gz" has all of the sources and was
     sufficient for the regenerate.bash script to complete.

This change does NOT regenerate the protos related to benchmarks.
The Protobuf repo no longer includes benchmarks. The CL removing them
says they are superceded by google/fleetbench:
    83c499de86
But that project's proto benchmark files are very different:
    https://github.com/google/fleetbench/tree/main/fleetbench/proto
So I commented out those steps in the generation code since the benchmarks
will need some work to reconcile with fleetbench.

This code adds known failing tests for conformance. New test cases were
added in https://github.com/protocolbuffers/protobuf/pull/9534, but the
Go protojson package does not behave according to the new tests. There
is an existing issue in GitHub about this:
    https://github.com/golang/protobuf/issues/1208

Change-Id: Iad796ec7889bc2a74b58db5224facf850cd1a1cd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/469255
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2023-02-22 09:33:03 +00:00
Oleksandr Redko
246af0d153 internal,reflect: correct typos
Fix typos in comments and unexported function name.

Change-Id: I239fff85bc68d7f0ef6f8853acdc9bbe19d86304
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/466535
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2023-02-09 09:27:51 +00:00
Oleksandr Redko
49eaa78c6c all: update links to Protocol Buffer documentation
https://developers.google.com/protocol-buffers/ states that
this site will be deprecated January 2023 and provides
https://protobuf.dev/ as a link to the new location.

Generated .pb.go files are created by generate.bash using Go 1.18,
so leave them unchanged for now.

Fixes golang/protobuf#1520.

Change-Id: I1ddf6f329c96ba05d7c7d8562ad2945f479ee09b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/466375
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2023-02-08 13:52:20 +00:00
Christian Höppner
e831c33179 proto: document Equal behavior of invalid messages
The doc comment of proto.Equal now explicitly describes the behavior
in the case when one message is valid and other is invalid.

Change-Id: Ifeba40277c7da25193d46ad496e910f9b63eb795
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/464275
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Chressie Himpel <chressie@google.com>
2023-02-07 08:52:30 +00:00
Pontus Leitzler
358fe40267 internal/strs: avoid unnecessary allocations in Builder
The grow() method in func did create a new internal byte slice with a
specific size instead of a specific capacity. As the call following
grow() is append() we ended up with a slice larger than needed.

It affects the memory consumption of programs that import generated
protobuf files. As an example with the following:

-- go.mod --
module x

go 1.20

require cloud.google.com/go/appengine v1.6.0
-- main.go --
package main

import _ "cloud.google.com/go/appengine/apiv1/appenginepb"

func main() {}

Running the following a few times:
$ go mod tidy && GODEBUG=inittrace=1 go run . 2>&1 | grep appenginepb

Before:
init cloud.google.com/go/appengine/apiv1/appenginepb @3.4 ms, 0.23 ms clock, 204624 bytes, 231 allocs
init cloud.google.com/go/appengine/apiv1/appenginepb @3.2 ms, 0.17 ms clock, 204688 bytes, 231 allocs
init cloud.google.com/go/appengine/apiv1/appenginepb @2.5 ms, 0.15 ms clock, 204400 bytes, 230 allocs
init cloud.google.com/go/appengine/apiv1/appenginepb @2.5 ms, 0.16 ms clock, 205552 bytes, 234 allocs

After:
init cloud.google.com/go/appengine/apiv1/appenginepb @3.3 ms, 0.19 ms clock, 143440 bytes, 226 allocs
init cloud.google.com/go/appengine/apiv1/appenginepb @2.7 ms, 0.16 ms clock, 144368 bytes, 229 allocs
init cloud.google.com/go/appengine/apiv1/appenginepb @2.8 ms, 0.16 ms clock, 144304 bytes, 229 allocs
init cloud.google.com/go/appengine/apiv1/appenginepb @3.1 ms, 0.16 ms clock, 142864 bytes, 224 allocs

Change-Id: If4ece5d70d6bd9de8a758cb29ce9dffc741c4951
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/465115
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2023-02-06 09:03:56 +00:00
Noriaki
0430d694e0 internal/impl: remove the unreachable line of code
Change-Id: Ie929703894858848c8465e0889d4fab04c1facc9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/463795
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2023-01-30 09:33:22 +00:00
Michael Stapelberg
a9481185b3 cmd/protoc-gen-go: make deprecated messages more descriptive
Also respect the file-wide deprecation option by treating every
identifier within the file as deprecated.

Change-Id: Ic3a5e84c2d90bbcbefc0a1b3272cc50554b94218
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/462315
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2023-01-18 09:34:59 +00:00
Samuel Benzaquen
31a5920811 protobuf: remove the check for reserved field numbers.
Field numbers in the reserved range are semantically valid,
although the protocol buffer compiler may reject attempts to
define fields in this range.

Change-Id: Ib939ed5f4fef09b29047b509829b2f01494bfb6a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/461238
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2023-01-12 08:45:15 +00:00
Mikhail Mazurskiy
a8d446d548 types/known/structpb: preallocate map in AsMap
Change-Id: I4fe676418959c23055e91d99a07ee3be8d466e25
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/460215
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2023-01-05 08:17:12 +00:00
Joe Tsai
b2a7dfe48b reflect/protoreflect: add Value.Equal method
The Value.Equal method compares Values in a way that is
analogous to the reflect.DeepEqual function.

Most of the implementation is moved from the "proto" package,
with proto.Equal implemented in terms of protoreflect.Value.Equal.

Change-Id: Ie9d5f6c073dc49fa59f78385c441db8137de5ec5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/450775
TryBot-Bypass: Heschi Kreinick <heschi@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Oleksii Prokopchuk <prokopchuk@google.com>
Reviewed-by: Christian Höppner <hoeppi@google.com>
Run-TryBot: Lasse Folger <lassefolger@google.com>
2022-12-01 15:36:18 +00:00
Damien Neil
f0e23c7a8f proto: revert expose package-private equalField
This reverts commit 4d6d2135eba33eaef1c020129188ce7e82aa4270.

Post-submit discussion on CL 448876 suggests that this API should
change; revert it pending a decision.

Change-Id: I2e81be847c62ea7de5dfef36bb10ab193132e612
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/450955
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Lasse Folger <lassefolger@google.com>
Run-TryBot: Lasse Folger <lassefolger@google.com>
TryBot-Bypass: Michael Stapelberg <stapelberg@google.com>
2022-11-16 08:31:27 +00:00
Oleksii Prokopchuk
4d6d2135eb proto: expose package-private equalField.
There is a demand for comparing protobuf.Value-s.
One use case is when one wants to compare just one field via reflection.
Another is when one wants to iterate over fields and check for diffs.
Existing diff packages are recommended only for tests as they panic on error.
Exposing equalField will prevent excessive branching of proto/equal.go code.

Change-Id: Iec8843dae96c9ae3c45858e8b97e7aa963473ce2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/448876
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Run-TryBot: Michael Stapelberg <stapelberg@google.com>
TryBot-Bypass: Michael Stapelberg <stapelberg@google.com>
2022-11-14 16:01:29 +00:00
Michael Stapelberg
7a48e2b662 protoreflect: fix list example code
Change-Id: I2c8afba104ae97be5e575226a47f6a7f20198abe
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/431798
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
2022-09-20 08:06:00 +00:00
Michael Stapelberg
494e81bd5a integration test: drop Go 1.11 and Go 1.12
fixes https://github.com/golang/protobuf/issues/1483

Change-Id: Ia5235f5923bc2430213d38bf5c6c5d0bcf25fa24
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/430516
Run-TryBot: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
2022-09-13 14:25:03 +00:00
Joe Tsai
f930b1dc76 encoding/protojson: fix parsing of google.protobuf.Timestamp
The Timestamp message uses a subset of RFC 3339.
RFC 3339, section 5.6 specifies that the subsecond field can have
any non-zero number of digits.
On the other hand, the protobuf documentation specifies that Timestamp
uses RFC 3339 with a few restrictions. In other words,
protobuf does NOT use RFC 3339, but rather a subset of it.

An upstream change https://go.dev/cl/425037 modifies the time package
to be internally consistent about handling of extra subsecond digits
allowing it to be more in line with RFC 3339.

Make a corresponding change here to ensure we remain compliant
with protobuf's restricted use of RFC 3339.

Change-Id: Ic145c68492fb41a5f7b79b653f3246dd9091d5d8
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/425554
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-08-31 09:28:52 +00:00
Josh Humphries
692f4a24f8 types/descriptorpb: update *.pb.go to use latest protoc release, 21.5
I updated the protoc version to 21.5 and ran regenerate.bash.

This updates the various *.pb.go files to use the sources from
the latest protobuf release. In particular, this updates the
descriptorpb, so it includes some changes to descriptor.proto
in the past year and a half since this was last re-generated.
The change also pulled over several other generated changes.

Change-Id: Icd9c4e5d47ba85e1f4bae1d0a025f8dec15a3014
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/426054
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-08-27 06:10:12 +00:00
Sachin Padmanabhan
fb0abd9158 encoding: add protodelim package
Fixes golang/protobuf#1382

Change-Id: I30dc9bf9aa44e35cde8fb472c3b8b116d459714e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/419254
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2022-08-02 22:27:24 +00:00
Lasse Folger
0f853484d7 all: start v1.28.1-devel
Change-Id: Ifa2563ae4661a99deaf015533d98413a38365797
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/419935
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2022-07-28 12:39:36 +00:00
Lasse Folger
6875c3d724 all: release v1.28.1
Change-Id: I2987633792a1429079cfebdf4c03d5629e4a448a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/419934
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
v1.28.1
2022-07-28 12:39:19 +00:00
Lasse Folger
881da6ece0 all: Add prebuild binaries for arm64
Change-Id: Ia8a0e2cce7a33c50d0064cb67a4e1c669cf8569b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/419714
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-07-28 06:45:07 +00:00
Russ Cox
2a74a0e823 A+C: delete AUTHORS and CONTRIBUTORS
In 2009, Google's open-source lawyers asked us to create the AUTHORS
file to define "The Go Authors", and the CONTRIBUTORS file was in
keeping with open source best practices of the time.

Re-reviewing our repos now in 2022, the open-source lawyers are
comfortable with source control history taking the place of the
AUTHORS file, and most open source projects no longer maintain
CONTRIBUTORS files.

To ease maintenance, remove AUTHORS and CONTRIBUTORS from all repos.

For #53961.

Change-Id: I6f3becd863672356de571303ff31434f517d959e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/418902
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-07-22 15:52:47 +00:00
Damien Neil
de9682ad16 internal/impl: improve MessageInfo.New performance
Calling the ProtoReflect method of the newly-constructed
message avoids an allocation in MessageInfo.MessageOf in
the common case of a generated message with an optimized
ProtoReflect method.

Benchmark for creating an empty message, darwin/arm64 M1 laptop:

    name                 old time/op    new time/op    delta
    EmptyMessage/New-10    32.1ns ± 2%    23.7ns ± 2%  -26.06%  (p=0.000 n=10+9)

    name                 old alloc/op   new alloc/op   delta
    EmptyMessage/New-10     64.0B ± 0%     48.0B ± 0%  -25.00%  (p=0.000 n=10+10)

    name                 old allocs/op  new allocs/op  delta
    EmptyMessage/New-10      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)

Change-Id: Ifa3c3ffa8edc76f78399306d0f4964eae4aacd28
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/418677
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-07-21 16:01:25 +00:00
Damien Neil
b0a944684d all: reformat with go1.19 gofmt
Apply go1.19 gofmt to non-generated files.

Generated .pb.go files are created by generate.bash using Go 1.18,
so leave them unchanged for now.

Change-Id: Ied36c83cf99704988d059bf0412e677f0fbc71b0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/418676
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-07-21 16:01:13 +00:00
Damien Neil
c1bbc5d45b all: make integration test work on darwin/arm64
Skip tests with Go versions prior to 1.16.

Bump test version for Go 1.17 and 1.18 to latest.

Change-Id: I740bbc63bf35362fcfad3cf0e07ea4bd0ee56748
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/418675
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-07-21 15:59:32 +00:00
Damien Neil
5f429f7042 proto: fix compilation failure in tests
Change-Id: I61a84dffcf4ccc9f81dc8b9f932c315713e81142
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/418674
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-07-21 06:22:01 +00:00
Koichi Shiraishi
fc44d00d5a proto: use reflect.Ptr for backward compatibility
reflect.Pointer introduced on go1.18. Support 1.17 and earlier.

Change-Id: I62dcdb580a7976068e86df432bc44ee21c2cda81
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/412354
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-06-17 06:55:02 +00:00
Mitko Asenov
380c339ec1 proto: short-circuit Equal when inputs are identical
I added benchmarks (measured on Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60GHz) that show the difference:

name                                  old time/op  new time/op  delta
EqualWithSmallEmpty-12                 241ns ± 6%   242ns ± 6%     ~     (p=0.796 n=10+10)
EqualWithIdenticalPtrEmpty-12          241ns ± 3%     7ns ± 4%  -97.19%  (p=0.000 n=10+10)
EqualWithLargeEmpty-12                2.68µs ± 3%  2.59µs ± 3%   -3.27%  (p=0.000 n=10+10)
EqualWithDeeplyNestedEqual-12         73.9µs ± 3%  71.8µs ± 1%   -2.91%   (p=0.000 n=10+9)
EqualWithDeeplyNestedDifferent-12     20.0µs ± 5%  19.4µs ± 5%   -3.06%  (p=0.029 n=10+10)
EqualWithDeeplyNestedIdenticalPtr-12  73.9µs ± 4%   0.0µs ± 2%  -99.99%  (p=0.000 n=10+10)

Change-Id: I1b83fa477d6432eafd355b322f507cf90b9a6751
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/411377
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2022-06-15 11:39:31 +00:00
Koichi Shiraishi
784c482554 all: remove shorthand import aliases
Change-Id: I62ec79419354a2c65ac69e4bcc1cc864a6a40a1a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/407934
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-05-24 20:05:50 +00:00
Koichi Shiraishi
e62d8edb75 all: remove duplicate imports
protoreflect (as pref) and protoiface (as piface) are imported
duplicates in some files.
Respect package name, remove unnecessary aliased import statements.

Change-Id: Ie9897f17a50d19a462035964e366af72afed0e4d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/405694
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-05-23 17:24:26 +00:00
Kir Kolyshkin
11ec34fe79 gha-ci: update github actions to latest versions
Update
 - actions/setup-go from v2 to v3;
 - actions/checkout from v2 to v3;
 - actions/cache from v2 to v3.0.2.

Tested at https://github.com/kolyshkin/protobuf-go/runs/6480937412

Change-Id: Ibeda7c83b1dfaf69dff1dab358b977958a48e51d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406846
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2022-05-23 16:51:27 +00:00
Kir Kolyshkin
147729ae80 gha-ci: bump Go version, nits
1. Switch from Go 1.16 to Go 1.x (which should now resolve to Go 1.18.1).

2. Add a comment explaining that the above version is not the actual Go
   version used for testing.

3. Drop -mod=vendor as this is the unconditional default since Go 1.16
   (unless GO111MODULES overrides this).

4. While at it, fix the options order in go test command, putting options
   before the file name.

Tested at https://github.com/kolyshkin/protobuf-go/actions/runs/2342081396

Change-Id: Icc9aa47ddc0d04abb69b48fcb6b021e3e8a98df3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406954
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-05-23 06:49:14 +00:00
Kir Kolyshkin
4790de629c all: update to latest staticcheck
The staticcheck version being used (2020.1.4) can no longer
work with latest Go, spitting out errors like this one:

> could not load export data: cannot import
> "unicode" (unknown iexport format version 2), export data is newer
> version - update tool (compile)

Update to latest version, 2022.1.2, to fix this.

Change-Id: I745482561a46baebc70931443008b95bec2fa377
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406842
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-05-19 15:39:12 +00:00
Damien Neil
f8e9eb526f internal/encoding/text: fix -0 comparisons in tests
Correctly distinguish between 0 and -0 in tests.

Change-Id: I41f6702a903ca0cf9edf9e95be812a3a29930978
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406917
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-05-19 09:42:31 +00:00
Kir Kolyshkin
bf9455640d all: fix typos
Brought to you by codespell v2.1.0, using the command

	codespell -S .cache,vendor -L ot,ba,fo,unparseable -w

Note that the misspelled "unparseable" comes from the
github.com/protocolbuffers/protobuf, where it is explicitly ignored
(see [1] and some explanation at [2]), so we ignore it here, too.

[1] https://github.com/protocolbuffers/protobuf/pull/7752
[2] https://github.com/protocolbuffers/protobuf/pull/7751#discussion_r460170422

Change-Id: Ie1ca705db4f11df8ec8b22fdc22b6a6ee667ae5b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406845
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-05-19 09:32:38 +00:00
Kir Kolyshkin
06eea5e15f internal/impl: CompressGZIP: simplify
This simplifies the code and fixes the following linter warning
reported by staticcheck:

        internal/impl/legacy_export.go:84:51: uint16(blockSize) ^ 0x0000 always equals uint16(blockSize) (SA4016)

Similar code:
 https://cs.opensource.google/go/go/+/master:src/compress/flate/huffman_bit_writer.go;l=413-414;drc=19309779ac5e2f5a2fd3cbb34421dafb2855ac21

Change-Id: Id099b0de635f668d44f57bacd89b564337560254
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406841
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2022-05-18 18:09:39 +00:00
Kir Kolyshkin
4db09f5dd7 all: add/bump tested Go versions
Add 1.18.1.

Bump 1.16.0 -> 1.16.15, 1.17.3 -> 1.17.10.

Change-Id: Ic19b47004484970b404e4eb8b2d02955410f65af
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406839
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-05-17 22:28:33 +00:00
Kir Kolyshkin
563f06fbeb internal/encoding/text/decode: limit errId length
Avoid very long errors returned by limiting the length of what errId
returns to 32 bytes (the value is chosen so that the error will not
be too long yet useful).

Append ellipsis to the returned value to denote that it was truncated.

Change-Id: I232d5192a2d9ad675daa0be0fe0c8518489c2953
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/406694
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-05-17 20:42:32 +00:00
Kir Kolyshkin
a0482351ba internal/encoding/text/decode: stop using regexp
This eliminates the last user of the regexp package, which should save
about 130K from the resulting stripped binary importing this package
(unless, of course, regexp is brought in directly of via another
dependency).

Added some new cases to TestDecoder to test the new function.

Benchmark (not included) shows the following results, comparing to
old implementation using regexp.Find:

name     old time/op    new time/op    delta
ErrId-4    1.93µs ± 1%    0.21µs ± 1%   -89.20%  (p=0.002 n=6+6)

name     old alloc/op   new alloc/op   delta
ErrId-4      128B ± 0%        0B       -100.00%  (p=0.002 n=6+6)

name     old allocs/op  new allocs/op  delta
ErrId-4      13.0 ± 0%       0.0       -100.00%  (p=0.002 n=6+6)

Change-Id: I5569a47580f41cc60f92c444e8d43bb3f26faa4e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/402774
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-05-16 20:59:57 +00:00
Joe Tsai
8a7ba0762c reflect/protoreflect: improve documentation for message types
There are a number of message types, which can be confusing.
Expand the documentation. In particular, use Go's reflection model
as an analogy, which helps users if they are at least familiar
with how Go reflection works. After all, protobuf reflection
was modeled after Go reflection to a large degree.

Change-Id: I388ae41c792905145ccc86dc938b901a2b79f408
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/399654
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
2022-04-12 06:05:53 +00:00
Lasse Folger
d77bd4b022 release.bash: replace aliased git commands with non-aliased equivalents
Change-Id: Ie9a9fd1d4cefc28c8fb5429a975ac50436e29d70
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/394454
Reviewed-by: Chressie Himpel <chressie@google.com>
Reviewed-by: Florian Zenker <floriank@google.com>
2022-03-22 12:18:24 +00:00
Lasse Folger
4c88e077ec all: start v1.28.0-devel
Change-Id: Ie9bd9f62312ff3f50787abd60067956b2911c59a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/391415
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
2022-03-22 07:56:25 +00:00
Lasse Folger
32051b4f86 all: release v1.28.0
Change-Id: Ied1d78a3cc0d417fbbd1d10d30730173af3e20d4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/391414
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
v1.28.0
2022-03-22 07:56:23 +00:00
Lasse Folger
3992ea83a2 all: implement depth limit for unmarshaling
+ This change introduce a default and configurable depth limit for
  proto.Unmarshal. If a message is nested deeper than the limit,
  unmarshaling will fail. There are two ways to nest messages. Either by
  having fields which are message types itself or by using groups.
+ The default limit is 10,000 for now. This might change in the future
  to align it with other language implementation (C++ and Java use 100
  as limit).
+ If pure groups (groups that don't contain message fields) are nested
  deeper than the default limit the unmarshaling fails with:
  proto: cannot parse invalid wire-format data
+ Note: the configured limit does not apply to pure groups.
+ This change is introduced to improve security and robustness. Because
  unmarshaling is implemented using recursion it can lead to stack overflows
  for certain inputs. The introduced limit protects against this.
+ A secondary motivation for this limit is the alignment with other
  languages. Protocol buffers are a language interoperability mechanism
  and thus either all implementations should accept the input or all
  implementation should reject the input.

Change-Id: I14bdb44d06e4bd1aa90d6336c2cf6446003b2037
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/385854
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2022-02-17 17:07:31 +00:00
Damien Neil
e5db2960ed all: update supported versions
Go 1.9 and 1.10 produce binaries that don't run on the most recent version
of macOS. Drop these versions from the tested set.

Update minor revision where a newer one is available:
  1.15.9 -> 1.15.15
  1.16.1 -> 1.16.10

Add 1.17.3.

Bump go.mod version to go1.11.

Fixes golang/protobuf#1394.

Change-Id: I7850b86819d356891917d2987f080d3e7dbd7cc5
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/370055
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Florian Zenker <floriank@google.com>
2022-01-04 22:58:13 +00:00
Damien Neil
3a9e1dc314 all: gofmt all
Change-Id: I1d42c8d784440a0b7e40b4f0b8da54be0fb338a6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/370054
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Florian Zenker <floriank@google.com>
2022-01-04 22:57:54 +00:00
Emmanuel T Odeke
26e8bcb3c7 all: remove unnecessary string([]byte) conversion in fmt.Sprintf with %s
Change-Id: I64aab811cbcbfa410817894f1cd1d83f88f27bf6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/365874
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-11-29 18:55:28 +00:00