Back to

Package proto

Latest Go to latest

The highest tagged major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module:


Package proto contains protobuf-related utilities.



var (
	// optional luci.Metadata file_metadata = 73700;
	E_FileMetadata = &file_go_chromium_org_luci_common_proto_options_proto_extTypes[0]

Extension fields to descriptor.FileOptions.

var File_go_chromium_org_luci_common_proto_options_proto protoreflect.FileDescriptor

func FixFieldMasksAfterMarshal

func FixFieldMasksAfterMarshal(jsonMessage []byte, messageType reflect.Type) ([]byte, error)

FixFieldMasksAfterMarshal reads FieldMask fields from a JSON-encoded message, and corrects incorrect Golang Protobuf library encoding according to It is a workaround for

This function is a reverse of FixFieldMasksBeforeUnmarshal.

messageType must be a struct, not a struct pointer.


func FixFieldMasksBeforeUnmarshal

func FixFieldMasksBeforeUnmarshal(jsonMessage []byte, messageType reflect.Type) ([]byte, error)

FixFieldMasksBeforeUnmarshal reads FieldMask fields from a JSON-encoded message, parses them as a string according to and converts them to a JSON serialization format that Golang Protobuf library can unmarshal from. It is a workaround for

This function is a reverse of FixFieldMasksAfterMarshal.

messageType must be a struct, not a struct pointer.


func ParseMultilineStrings

func ParseMultilineStrings(text string) (string, error)

ParseMultilineStrings looks for bash-style heredocs and replaces them with single-line text-proto-escaped strings.

This looks line by line for /<<\s*([_a-zA-Z]+)\s*$/. If this is found, the scanner then looks until it finds /^\s*\1\s*$/. Every line between these is joined like "\n".join(lines), and then printed back as an escaped proto string. The scanner then loops back to its initial state.

Not that nothing special needs to be done for e.g.

some_key: "string with << angles"

Such a line would be left alone, because the trailing quote (which is mandatory in text proto) cause the starting regex to not match.

For convenience, the inner lines will be treated with the equivalent of python's `textwrap.dedent`; any common leading whitespace that occurs on every line will be removed. Although both tabs and spaces count as whitespace, they are not equivalent (i.e. only exactly-matching whitespace prefixes count)

The only error this may return is if there's an open heredoc without a matching close marker.


  this: <<EOF
	   turn \ninto
      a "single"

Turns into the same as:

this: "would\nturn \\ninto\n  a \"single\"\nline"

func UnmarshalTextML

func UnmarshalTextML(s string, pb proto.Message) error

UnmarshalTextML behaves the same as proto.UnmarshalText, except that it allows for multiline strings in the manner of ParseMultilineStrings.

type Metadata

type Metadata struct {

	// URL to a human-readable proto schema definition doc.
	DocUrl *string `protobuf:"bytes,1,opt,name=doc_url,json=docUrl" json:"doc_url,omitempty"`
	// contains filtered or unexported fields

func (*Metadata) Descriptor

func (*Metadata) Descriptor() ([]byte, []int)

Deprecated: Use Metadata.ProtoReflect.Descriptor instead.

func (*Metadata) GetDocUrl

func (x *Metadata) GetDocUrl() string

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) ProtoReflect

func (x *Metadata) ProtoReflect() protoreflect.Message

func (*Metadata) Reset

func (x *Metadata) Reset()

func (*Metadata) String

func (x *Metadata) String() string

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier