Package quickdump

import "github.com/byte-mug/golibs/quickdump"

Overview

QuickDump, a PreciseIO based simple Serialization system, that is much easier to use than serializer.

QuickDump is capable to serialize structures without any need to previously create serializers for it.

As a limitation: QuickDump is strictly typed - "interface{}" does not work at all. Also QuickDump is brittle. Wrong types will cause QuickDump to panic.

Nullable

By default every pointer is a NULLable (implicitely). You can cause every NULLable value to be treated as non-nullable by setting the quickdump:"strip" tag. You can also explicitely mark a value as NULLable, if it's type supports it, by setting the quickdump:"nullable" tag.

Here are the examples of nullable values:

Nullable1 *DesiredType                         `quickdump:"nullable"` // NULLable by default, but we made it explicitely.
Nullable2 struct{ Ok bool; Data DesiredType }  `quickdump:"nullable"` // If Ok is false, value is NULL

Variants

Variants are a sequence of Fields, where ony one of them will be serialized. They are used to implement some kind of Dynamic Typing/Polymorphism.

type Variant struct{
	Alpha *Alpha  `quickdump:"tag,strip"`
	Beta  *Beta   `quickdump:"more,strip"`
	Gamma *Gamma  `quickdump:"more,strip"`
}

Index

func Marshal

func Marshal(w *preciseio.PreciseWriter, i interface{}) error

-

func Unmarshal

func Unmarshal(r preciseio.PreciseReader, i interface{}) error

-

Dependencies