encoding

package
v0.15.1-dev Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Exts = []string{
	JSONExt,
	YAMLExt,

	".yml",
}

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

View Source
var JSONExt = ".json"
View Source
var Marshalers map[string]Marshaler

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

View Source
var YAMLExt = ".yaml"

Functions

func DefaultExt

func DefaultExt() string

DefaultExt returns the default extension to use.

Types

type Marshaler

type Marshaler interface {
	IsJSONLike() bool
	IsYAMLLike() bool
	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{}
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.

Jump to

Keyboard shortcuts

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