-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proto: add example for GetExtension, SetExtension
(Adding an example to HasExtension as well seemed too much to me.) The example message uses the same example names as the Generated Code Reference: https://protobuf.dev/reference/go/go-generated-opaque/#extensions The definition follows the Language Guide: https://protobuf.dev/programming-guides/editions/#extensions For golang/protobuf#1528 Change-Id: I7c5c4a0ac954678a5e0b10015374377b32bd7634 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641876 Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Chressie Himpel <[email protected]>
- Loading branch information
1 parent
de043b9
commit 2f60868
Showing
3 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
edition = "2023"; | ||
|
||
package goproto.proto.test; | ||
|
||
import "google/protobuf/go_features.proto"; | ||
|
||
option go_package = "google.golang.org/protobuf/internal/testprotos/examples/ext"; | ||
option features.(pb.go).api_level = API_OPAQUE; | ||
|
||
message Concert { | ||
string headliner_name = 1; | ||
|
||
extensions 100 to 199 [ | ||
declaration = { | ||
number: 123, | ||
full_name: ".goproto.proto.test.promo_id", | ||
type: "int32", | ||
}, | ||
// Ensures all field numbers in this extension range are declarations. | ||
verification = DECLARATION | ||
]; | ||
} | ||
|
||
// Typically, this extension would be declared in a separate file, | ||
// but for brevity, we declare the entire example in one file. | ||
extend Concert { | ||
int32 promo_id = 123; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters