encoding

package
v3.63.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JSONExt = ".json"
	YAMLExt = ".yaml"
	GZIPExt = ".gz"
)
View Source
var Exts = []string{
	JSONExt,
	YAMLExt,

	".yml",
}

Exts contains a list of all the valid marshalable extension types.

View Source
var Marshalers map[string]Marshaler

Marshalers is a map of extension to a Marshaler object for that extension.

Functions

func DefaultExt

func DefaultExt() string

DefaultExt returns the default extension to use.

func IsCompressed added in v3.33.2

func IsCompressed(buf []byte) bool

IsCompressed returns if data is zip compressed.

Types

type Marshaler

type Marshaler interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

Marshaler is a type that knows how to marshal and unmarshal data in one format.

var JSON Marshaler = &jsonMarshaler{}

JSON is a Marshaler that marshals and unmarshals JSON with indented printing.

var YAML Marshaler = &yamlMarshaler{}

func Default

func Default() Marshaler

Default returns the default marshaler object.

func Detect

func Detect(path string) (Marshaler, string)

Detect auto-detects a marshaler for the given path.

func Gzip added in v3.33.2

func Gzip(m Marshaler) Marshaler

Jump to

Keyboard shortcuts

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