package defval

import "google.golang.org/protobuf/internal/encoding/defval"

Package defval marshals and unmarshals textual forms of default values.

This package handles both the form historically used in Go struct field tags and also the form used by google.protobuf.FieldDescriptorProto.default_value since they differ in superficial ways.

Index

Functions

func Marshal

Marshal serializes v as the default string according to the given kind k. When specifying the Descriptor format for an enum kind, the associated enum value descriptor must be provided.

func Unmarshal

Unmarshal deserializes the default string s according to the given kind k. When k is an enum, a list of enum value descriptors must be provided.

Types

type Format

type Format int

Format is the serialization format used to represent the default value.

const (

	// Descriptor uses the serialization format that protoc uses with the
	// google.protobuf.FieldDescriptorProto.default_value field.
	Descriptor Format

	// GoTag uses the historical serialization format in Go struct field tags.
	GoTag
)

Source Files

default.go

Version
v1.36.5 (latest)
Published
Feb 6, 2025
Platform
linux/amd64
Imports
6 packages
Last checked
10 hours ago

Tools for package owners.