luci-go: github.com/luci/luci-go/common/proto Index | Files | Directories

package proto

import "github.com/luci/luci-go/common/proto"

Package proto contains protobuf-related utilities.

Index

Package Files

doc.go fieldmasks.go multiline.go options.pb.go

Variables

var E_FileMetadata = &proto.ExtensionDesc{
    ExtendedType:  (*descriptor.FileOptions)(nil),
    ExtensionType: (*Metadata)(nil),
    Field:         73700,
    Name:          "luci.file_metadata",
    Tag:           "bytes,73700,opt,name=file_metadata",
    Filename:      "go.chromium.org/luci/common/proto/options.proto",
}

func FixFieldMasksAfterMarshal Uses

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 https://github.com/protocolbuffers/protobuf/blob/ec1a70913e5793a7d0a7b5fbf7e0e4f75409dd41/src/google/protobuf/field_mask.proto#L180 It is a workaround for https://github.com/golang/protobuf/issues/745.

This function is a reverse of FixFieldMasksBeforeUnmarshal.

messageType must be a struct, not a struct pointer.

WARNING: AVOID. LIKELY BUGGY, see https://crbug.com/1028915.

func FixFieldMasksBeforeUnmarshal Uses

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 https://github.com/protocolbuffers/protobuf/blob/ec1a70913e5793a7d0a7b5fbf7e0e4f75409dd41/src/google/protobuf/field_mask.proto#L180 and converts them to a JSON serialization format that Golang Protobuf library can unmarshal from. It is a workaround for https://github.com/golang/protobuf/issues/745.

This function is a reverse of FixFieldMasksAfterMarshal.

messageType must be a struct, not a struct pointer.

WARNING: AVOID. LIKELY BUGGY, see https://crbug.com/1028915.

func ParseMultilineStrings Uses

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.

Example:

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

Turns into the same as:

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

func UnmarshalTextML Uses

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 Uses

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"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*Metadata) Descriptor Uses

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

func (*Metadata) GetDocUrl Uses

func (m *Metadata) GetDocUrl() string

func (*Metadata) ProtoMessage Uses

func (*Metadata) ProtoMessage()

func (*Metadata) Reset Uses

func (m *Metadata) Reset()

func (*Metadata) String Uses

func (m *Metadata) String() string

func (*Metadata) XXX_DiscardUnknown Uses

func (m *Metadata) XXX_DiscardUnknown()

func (*Metadata) XXX_Marshal Uses

func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metadata) XXX_Merge Uses

func (m *Metadata) XXX_Merge(src proto.Message)

func (*Metadata) XXX_Size Uses

func (m *Metadata) XXX_Size() int

func (*Metadata) XXX_Unmarshal Uses

func (m *Metadata) XXX_Unmarshal(b []byte) error

Directories

PathSynopsis
accessPackage access contains Access service protocol.
configPackage config contains luci-config protobuf definitions.
examplesPackage examples shows how to design protos which adhere to the Google Cloud API design guide.
gerritPackage gerrit contains Gerrit service definition.
gitPackage git contains Git-related protobuf definitions.
gitilesPackage gitiles contains Gitiles service definition.
googlePackage google contains utility methods to help interface between Google standard protobufs and native Go types.
google/descutilPackage descutil contains utility functions for protobuf descriptor messages.
miloPackage milo contains Milo protobuf definitions.
pagedPackage paged implements a helper for making paginated Datastore queries.
srcmanPackage srcman contains source manifest protobuf definitions.

Package proto imports 14 packages (graph) and is imported by 1 packages. Updated 2019-12-05. Refresh now. Tools for package owners.