I'm trying to use following DB API: https://godoc.org/github.com/syndtr/goleveldb/leveldb# (simple file based key/value DB)
I was able to put and get "key"s into the database. However, I'm wondering if value can be a struct such as:
type Thm struct {
Name string
Age int
}
Then,
var Tmp Thm
Tmp.Name = "Gon"
Tmp.Age = 33
db.Put([]byte("test3"), []byte(Tmp), nil)
Right now, the error I'm getting is "cannot covert Tmp (type Thm) to type []byte.
If you have experiences with levelDB, could you help me how normally this will be done? OR, should I convert struct into byte in order to make this work?
Thank you