Encode/Decode between struct and byte slice

Date: Wed, Jan 28, 2015

This is handy if you need to send a struct to a database or network


sbs stands for Struct to Byte Slice and back to Struct

Internals:

sbs encodes your struct first to a Gob, then it convers it to a byte slice; it reverses the process for decoding.

Example


	type Foo struct {
		A int
		B string
	}

	p := &Foo{111,"A string"}

	byteslice, err := sbs.Enc(p)
	...

	foo := new(Foo)
	structobject, err := sbs.Dec(foo, byteslice)
	...

Code is available at https://bitbucket.org/gotamer/sbs