https://github.com/emcfarlane/starlarkproto
Support protobuffers in Starlark
https://github.com/emcfarlane/starlarkproto
Last synced: over 1 year ago
JSON representation
Support protobuffers in Starlark
- Host: GitHub
- URL: https://github.com/emcfarlane/starlarkproto
- Owner: emcfarlane
- License: bsd-3-clause
- Created: 2020-03-01T17:57:13.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-03-20T21:10:54.000Z (over 2 years ago)
- Last Synced: 2024-04-21T00:58:22.356Z (about 2 years ago)
- Language: Go
- Size: 190 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# starlarkproto
[](https://pkg.go.dev/github.com/emcfarlane/starlarkproto?tab=doc)
Supports protobuffers in starlark with rich type conversion to and from starlark. Most methods on lists and maps are supported, see package internals for details.
```python
test = proto.file("github.com/emcfarlane/starlarkproto/testpb/star.proto")
m = test.Message(body="Hello, world!")
print(m) # Message(body = Hello, world!, type = UNKNOWN, ...)
m.type = "GREETING" # Enums can be assigned by String, Int or proto.Enum
print(m) # Message(body = Hello, world!, type = GREETING, ...)
greeting = test.Message.Type.GREETING
print(greeting) # GREETING
data = proto.marshal(m) # Byte encoded string
m2 = test.Message()
proto.unmarshal(data, m2) # Unmarshal back to message
```