bson

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package bson provides an API for BSON serialization. This package wraps the mgo bson package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyInput  = errors.New("empty input")
	ErrInvalidRune = errors.New("invalid rune")
)
View Source
var (
	DefaultType = reflect.TypeOf(map[string]interface{}{})
)

Functions

func Marshal

func Marshal(obj interface{}) ([]byte, error)

Marshal formats an object into a slice of bytes of BSON.

func Unmarshal

func Unmarshal(b []byte) (interface{}, error)

Unmarshal parses a slice of bytes into an object using a few simple type inference rules. This package is useful when your program needs to parse data, that you have no a priori awareness of its structure or type. If no input is given, then returns ErrEmptyInput.

func UnmarshalType

func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error)

UnmarshalType parses a slice of bytes into an object of a given type. If no input is given, then returns ErrEmptyInput.

Types

type ErrInvalidKeys

type ErrInvalidKeys struct {
	Value reflect.Type
}

func (ErrInvalidKeys) Error

func (e ErrInvalidKeys) Error() string

type ErrInvalidKind

type ErrInvalidKind struct {
	Value    reflect.Type
	Expected []reflect.Kind
}

func (ErrInvalidKind) Error

func (e ErrInvalidKind) Error() string

Jump to

Keyboard shortcuts

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