form

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package form contains a DB's marshal/unmarshal behaviour.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFormExists occurs when you attempt to register to a known form name.
	ErrFormExists = errors.New("form exists")

	// ErrUnknownForm occurs when you attempt to get a form that isn't registered.
	ErrUnknownForm = errors.New("unknown form")
)
View Source
var Default = "json"

Default is the name of the default form to load.

Functions

func Add

func Add(name string, f Form)

Add puts the given Form into the registry. Panics with ErrFormExists if the name is already registered.

func Del

func Del(name string)

Del removes the named Form from the registry.

func Names

func Names() []string

Names returns the registered Form names.

Types

type Form

type Form interface {
	Marshal(interface{}) ([]byte, error)
	Unmarshal([]byte, interface{}) error
}

Form defines a pair of marshal/unmarshal behaviours.

func Get

func Get(name string) (Form, error)

Get returns the named Form, or the one named by Default. Returns ErrUnknownForm if no Form is found.

Directories

Path Synopsis
Package json contains a Form implementation that wraps encoding/json.
Package json contains a Form implementation that wraps encoding/json.

Jump to

Keyboard shortcuts

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