Answer the question
In order to leave comments, you need to log in
Is it possible to do this better?
My task is as follows:
I have 100500 elements. key, value []byte
I need to collect all this in 1 []byte and easily decode it into 100500 key, value []byte
.
Now I have reached the baseline. Bytes circulate over the network in this format
type D struct {
C uint8
Db string
Key, Value []byte
}
type Map struct {
Key, Value []byte
}
func EncodeDecodeTest(t *testing.T) {
d := []uint8{Get, Set, Up, Del}
for key := range d {
g := D{}
g.C = d[key]
g.Db = "db"
g.Key = []byte("sdfsdfsdfsdfsdf")
g.Value = []byte("dsdfsdfs35345dfsdf")
gg := Decode(Encode(g))
if g.C != gg.C {
t.Error(g.C, gg.C)
}
if g.Db != gg.Db {
t.Error(g.Db, gg.Db)
}
if !slice.ByteSame(g.Key, gg.Key) {
t.Error(g.Key, gg.Key)
}
if !slice.ByteSame(g.Value, gg.Value) {
t.Error(g.Value, gg.Value)
}
}
}
Answer the question
In order to leave comments, you need to log in
What the hell are you doing? The task is minute.
https://www.google.com/?ion=1&espv=2#q=golang+serialize
https://www.google.com/?ion=1&espv=2#q=golang+json
https://www. google.com/?ion=1&espv=2#q=golang+xml
https://www.google.com/?ion=1&espv=2#q=golang+bina...
https://www.google.com /?ion=1&espv=2#q=golang+gob
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question