defval

package
v2.0.0-...-d24bc72 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v pref.Value, k pref.Kind, f Format) (string, error)

Marshal serializes v as the default string according to the given kind k. Enums are serialized in numeric form regardless of format chosen.

func Unmarshal

func Unmarshal(s string, k pref.Kind, f Format) (pref.Value, error)

Unmarshal deserializes the default string s according to the given kind k. When using the Descriptor format on an enum kind, a Value of type string representing the enum identifier is returned. It is the caller's responsibility to verify that the identifier is valid.

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
)

Jump to

Keyboard shortcuts

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