Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 853 Bytes

README.md

File metadata and controls

20 lines (15 loc) · 853 Bytes

starlarkproto

GoDev

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.

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