@@ -118,9 +118,24 @@ When defining APIs, the following rules apply:
118118 option php_namespace = "Google\\Cloud\\AccessApproval\\V1";
119119 option ruby_package = "Google::Cloud::AccessApproval::V1";
120120 ```
121+ - The `go_package` value depends directly on how the Go code is managed i.e.
122+ if the module name is based on the VCS provider or using a remote import
123+ path, but often has a consistent structure.
124+ - The module **may** differ based on product area e.g.
125+ `google.cloud.accessapproval.v1` would be in module
126+ `cloud.google.com/go/accessapproval`.
127+ - The package import path **should** be derived from the proto package.
128+ - An API version in the proto package **should** be prefixed with `api` e.g.
129+ the proto package segment `v1` becomes `apiv1`.
130+ - The terminal import path segment **should** be based on the product name
131+ found within the proto package and **must** be suffixed with `pb` e.g.
132+ `accessapproval` becomes `accessapprovalpb`.
133+ - This value **should** be left to the team owning the generated code to
134+ decide on.
121135
122136All packaging annotations **should** be specified in alphabetical order of
123- name.
137+ name. Refer to the [Protobuf documentation][package docs] for more about
138+ language package options.
124139
125140**Important:** While languages other than Java have sensible defaults for APIs
126141which don't include compound names, be aware that _adding_ this annotation
@@ -138,9 +153,22 @@ required in combination with `java_multiple_files`. It instructs `protoc` to
138153wrap each compiled Protobuf type in a Java class whose name is the value of the
139154option. This prevents potential naming collisions between generated types.
140155
156+
157+ ### Go packaging option
158+
159+ The Go packaging option needs to be decided by the team that owns the generated
160+ code, because it is directly tied to the source code management practices of the
161+ team. Allowing every proto package to decide on their own Go package creates
162+ inconsistencies and friction in management of the code. Within that owning team,
163+ having a consistent structure in the Go package naming is critical to a
164+ consistent end user experience.
165+
141166## Changelog
142167
168+ - **2024-06-13**: Added guidance for Go packaging annotation.
143169- **2024-06-05**: Added rationale for Java packaging options.
144170- **2023-02-24**: Added guidance on protobuf syntax.
145171- **2022-10-18**: Added guidance on Ruby/PHP/C# options.
146172- **2019-11-18**: Added guidance on the packaging annotations.
173+
174+ [package docs]: https://protobuf.dev/programming-guides/proto3/#packages
0 commit comments