godat

package module
v0.0.0-...-52317c4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: MIT Imports: 9 Imported by: 0

README

godat - Simple data serializer for Go 1.7+

Build Status codecov License

Install

go get github.com/lokhman/godat

Usage

import "github.com/lokhman/godat"

func main() {
    var anyData = ...
    var unserializedData ...

    serializedBytes, err := godat.Marshal(anyData)
    if err != nil {
        panic(err)
    }
    
    err = godat.Unmarshal(serializedBytes, &unserializedData)
    if err != nil {
        panic(err)
    }
    
    // anyData == unserializedData
}

Tests

Use go test for testing.

License

Library is available under the MIT license. The included LICENSE file describes this in detail.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump

func Dump(filename string, v interface{}, vv ...interface{}) error

func Load

func Load(filename string, v interface{}, vv ...interface{}) error

func Marshal

func Marshal(v interface{}, vv ...interface{}) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte, v interface{}, vv ...interface{}) error

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) error

func (*Decoder) DecodeValue

func (d *Decoder) DecodeValue(v reflect.Value) error

type DecoderError

type DecoderError struct {
	ErrorString string
}

func (DecoderError) Error

func (e DecoderError) Error() string

type DecoderTypeError

type DecoderTypeError struct {
	Value string
	Type  reflect.Type
}

func (DecoderTypeError) Error

func (e DecoderTypeError) Error() string

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) error

func (*Encoder) EncodeValue

func (e *Encoder) EncodeValue(v reflect.Value) error

type EncoderError

type EncoderError struct {
	ErrorString string
}

func (EncoderError) Error

func (e EncoderError) Error() string

Jump to

Keyboard shortcuts

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