tag

package
v1.99.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package tag marshals and unmarshals the legacy struct tags as generated by historical versions of protoc-gen-go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(fd pref.FieldDescriptor, enumName string) string

Marshal encodes the protoreflect.FieldDescriptor as a tag.

The enumName must be provided if the kind is an enum. Historically, the formulation of the enum "name" was the proto package dot-concatenated with the generated Go identifier for the enum type. Depending on the context on how Marshal is called, there are different ways through which that information is determined. As such it is the caller's responsibility to provide a function to obtain that information.

func Unmarshal

func Unmarshal(tag string, goType reflect.Type, evs pref.EnumValueDescriptors) pref.FieldDescriptor

Unmarshal decodes the tag into a prototype.Field.

The goType is needed to determine the original protoreflect.Kind since the tag does not record sufficient information to determine that. The type is the underlying field type (e.g., a repeated field may be represented by []T, but the Go type passed in is just T). A list of enum value descriptors must be provided for enum fields. This does not populate the Enum or Message (except for weak message).

This function is a best effort attempt; parsing errors are ignored.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL