https://github.com/rodaine/protoc-gen-visibility
Cascading visibility rules for protobufs
https://github.com/rodaine/protoc-gen-visibility
buf protoc protoc-plugin protocol-buffers
Last synced: about 1 year ago
JSON representation
Cascading visibility rules for protobufs
- Host: GitHub
- URL: https://github.com/rodaine/protoc-gen-visibility
- Owner: rodaine
- License: mit
- Created: 2023-01-13T01:52:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-14T15:59:17.000Z (about 1 year ago)
- Last Synced: 2025-03-14T16:41:49.469Z (about 1 year ago)
- Topics: buf, protoc, protoc-plugin, protocol-buffers
- Language: Go
- Homepage:
- Size: 160 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# protoc-gen-visibility
_Set cascading visibility rules for Protocol Buffer files, messages, and enums._
## Example
```protobuf
// ./protos/widgets/v1/widget.proto
syntax = "proto3";
package widgets.v1;
import "visibility/v1/visibility.proto";
option (visibility.v1.file_rules) = {
mode: MODE_PACKAGE, // entities in this file are package-private...
packages: [ // ...and also visible to these packages:
"gizmos.v1",
"gadgets.*"
]
};
// ...
```
`protoc-gen-visibility` is executed like any other protoc plugin, but does not generate output files. The plugin errors if there is a violation of the visibility specificiation:
```shell
$ protoc --visibility_out=. ./protos/gadgets/v1/gadget.proto
# exits 0
$ protoc --visibility_out=. ./protos/gizmos/v2/gizmo.proto
--visibility_out: visibility constraints have been violated:
- protos/gizmos/v2/gizmo.proto: gizmos.v2.Gizmo includes widgets.v1.Widget (MODE_PACKAGE)
# exits 1
```