Documentation
¶
Overview ¶
Package gob provides support for reading and writing a stream of gob-encoded obejcts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingType = errors.New("missing type") ErrInvalidType = errors.New("invalid type, expecting map or struct") )
Functions ¶
func RegisterTypes ¶
func RegisterTypes()
RegisterTypes registers some default types that are not registered by default by the standard library gob package.
func Write ¶
func Write(input *WriteInput) error
Write writes the given object(s) as gob-encoded items. As gob is a stream encoding, if provded an object of array or slice, then each contained element is written as its own item. If not provided an array or slice, then the provided object is encoded as is as a gob item.
Types ¶
type Encoder ¶
func NewEncoder ¶
Encoder returns a new gob encoder given the underlying writer.
type Iterator ¶
type Iterator struct { Type reflect.Type // the type to unmarshal for each item Decoder *stdgob.Decoder // the scanner that splits the underlying stream of bytes Limit int // Limit the number of objects to read and return from the underlying stream. Count int // The current count of the number of objects read. }
Iterator iterates trough a stream of bytes returning a new object on each call of Next() until it reaches the end and returns io.EOF.
func NewIterator ¶
func NewIterator(input *NewIteratorInput) *Iterator
NewIterator returns a new gob iterator base on the given input.
func (*Iterator) Next ¶
Next reads from the underlying reader and returns the next object and error, if any. If a blank line is found and SkipBlanks is false, then returns (nil, nil). If a commented line is found and SkipComments is false, then returns (nil, nil). When the input stream is exhausted, returns (nil, io.EOF).
type NewIteratorInput ¶
type NewIteratorInput struct { Reader io.Reader Type reflect.Type // the type to unmarshal for each line Limit int // Limit the number of objects to read and return from the underlying stream. }
Input for NewIterator function.
type ReadInput ¶
type ReadInput struct { Type reflect.Type // the output type Reader io.Reader // the underlying reader Limit int }
ReadInput provides the input parameters for the Read function.
type WriteInput ¶
type WriteInput struct { Writer io.Writer // the underlying writer Object interface{} // the object to write Limit int Fit bool }
WriteInput provides the input for the Write function.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer formats and writes objects to the underlying writer as gob-encoded items.
func NewWriter ¶
NewWriter returns a writer for formating and writing objets to the underlying writer as gob-encoded items.
func (*Writer) Flush ¶
Flush flushes the underlying writer, if it has a Flush method. This writer itself does no buffering.
func (*Writer) WriteObject ¶
WriteObject formats and writes a single object to the underlying writer as a gob-encoded item.
func (*Writer) WriteObjects ¶
WriteObjects formats and writes the given objects to the underlying writer.