format

package
v0.0.0-...-bc6fd34 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidUnmarshaler = Format{"INVALID", nil}

InvalidUnmarshaler is used when no valid unmarshaler can be found

Functions

func RegisterDataFormat

func RegisterDataFormat(name string, unmarshaler Unmarshaler)

RegisterDataFormat manages input format for data

Types

type Format

type Format struct {
	Name        string
	Unmarshaler Unmarshaler
}

Format is a decoding format

func ByName

func ByName(name string) Format

ByName return the FOrmat with the given name

func FindBest

func FindBest(filename string) Format

FindBest searches for the best format for decoding the file This is done by searching the filename suffix(usually the extension) and the prefix

func Registered

func Registered() []Format

Registered returns a slice with all the registered formats

func (*Format) Unmarshal

func (f *Format) Unmarshal(raw []byte) (interface{}, error)

Unmarshal use the Format unmarshaler to unmarshal the data

type Unmarshaler

type Unmarshaler interface {
	//Unmarshal takes the raw data as input and decodes it into the interface{}
	Unmarshal(raw []byte) (interface{}, error)
}

Unmarshaler is used to unmarshal the data

Jump to

Keyboard shortcuts

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