1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-10 18:10:49 +09:00

fix copy struct

This commit is contained in:
Sergey Cherepanov 2020-04-17 13:31:51 +03:00
parent dac849175f
commit 88c05033e3
No known key found for this signature in database
GPG key ID: 085319C64294F576
3 changed files with 21 additions and 7 deletions

View file

@ -367,9 +367,9 @@ func (c *collector) close() {
}
func copyMeta(m Meta) Meta {
var d *types.Struct
d := m.Details
if d != nil {
d = pbtypes.CopyStruct(m.SmartBlockMeta.Details)
d = pbtypes.CopyStruct(m.Details)
}
return Meta{
BlockId:

View file

@ -13,11 +13,6 @@ var bytesPool = &sync.Pool{
},
}
type Type interface {
Size() int
MarshalToSizedBuffer(data []byte) (int, error)
}
func CopyBlock(in *model.Block) (out *model.Block) {
buf := bytesPool.Get().([]byte)
size := in.Size()

19
util/pbtypes/copy_test.go Normal file
View file

@ -0,0 +1,19 @@
package pbtypes
import (
"testing"
"github.com/gogo/protobuf/types"
"github.com/stretchr/testify/assert"
)
func TestCopyStruct(t *testing.T) {
s := &types.Struct{
Fields: map[string]*types.Value{
"string": String("string"),
"bool": Bool(true),
},
}
c := CopyStruct(s)
assert.True(t, s.Equal(c))
}