encoder

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StructTagKey = "param"
	// StructTagDelimiter used to separate items in struct tags.
	StructTagDelimiter = ","
	// StructTagSeparator used for defining key/value flags in struct tags.
	StructTagSeparator = "="
	// StructTagFlagOmitEmpty used to determine whether the field can be omitted if it's Value is empty or not.
	StructTagFlagOmitEmpty = "omitempty"
)

Variables

This section is empty.

Functions

func MarshalParams

func MarshalParams(v interface{}) (types.Params, error)

Types

type ParamsMarshaler

type ParamsMarshaler interface {
	MarshalParams(key string) (types.Params, error)
}

type StructTag

type StructTag struct {
	// Key name which is the first item of a struct tag
	Key string
	// Flags
	OmitEmpty bool
}

StructTag stores information about the struct tags which includes the name of the Key and optional flags like `omitempty`.

func ParseStructTag

func ParseStructTag(s string) (*StructTag, error)

ParseStructTag returns a pointer to a StructTag object holding the information resulted from parsing the s string as a struct tag.

func (StructTag) Skip

func (t StructTag) Skip() bool

Skip returns true if the Key field of the structTag is either an empty string or `-` meaning that the struct field should not be considered during marshal/unmarshal.

type StructTagFlag

type StructTagFlag struct {
	Key   string
	Value string
}

StructTagFlag holds information about flags defined for a struct tag in a Key/Value format.

func ParseStructTagFlag

func ParseStructTagFlag(s string) (*StructTagFlag, error)

ParseStructTagFlag returns a pointer to a StructTagFlag object holding the information resulted from parsing the s string as a struct tag flag.

func (StructTagFlag) IsValid

func (f StructTagFlag) IsValid() bool

IsValid considers f StructTagFlag valid if Key field is a non-empty string.

Jump to

Keyboard shortcuts

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