On Mon, Mar 31, 2014 at 08:39:20AM -0700, Juan Torres wrote:
> Hello, i´m trying to use the package kv (
https://github.com/cznic/kv) and
> the method Set and the param is a array byte
>
> func (db *DB) Set(key, value []byte) (err error) {
> ...
> }
> and i would like to convert one structure to array byte..
Given the data store, I assume your program is the only consumer
of the encoded values. In that case encoding/gob
should work fine for you. Here's a usage example.
http://play.golang.org/p/frZq8YbcAb
Just FYI, there are other encoding mechanisms as well: json, bson, msgpack,
etc, etc. Depending on who else needs to read the data (humans included),
one or the other may be a better fit, but the process is about the same
in all cases.
-Gyepi