diff --git a/cmd/neofs-node/attributes.go b/cmd/neofs-node/attributes.go index 8fa0475b02..d4f962dbe2 100644 --- a/cmd/neofs-node/attributes.go +++ b/cmd/neofs-node/attributes.go @@ -16,7 +16,7 @@ const ( defaultPrice = 0 ) -func parseAttributes(c *config.Config) []*netmap.NodeAttribute { +func parseAttributes(c *config.Config) []netmap.NodeAttribute { if nodeconfig.Relay(c) { return nil } @@ -44,7 +44,7 @@ func listWellKnownAttrDesc() map[string]wellKnownNodeAttrDesc { } } -func addWellKnownAttributes(attrs []*netmap.NodeAttribute) []*netmap.NodeAttribute { +func addWellKnownAttributes(attrs []netmap.NodeAttribute) []netmap.NodeAttribute { mWellKnown := listWellKnownAttrDesc() // check how user defined well-known attributes @@ -59,11 +59,10 @@ func addWellKnownAttributes(attrs []*netmap.NodeAttribute) []*netmap.NodeAttribu } // set default value of the attribute - a := netmap.NewNodeAttribute() - a.SetKey(key) - a.SetValue(desc.defaultVal) - - attrs = append(attrs, a) + index := len(attrs) + attrs = append(attrs, netmap.NodeAttribute{}) + attrs[index].SetKey(key) + attrs[index].SetValue(desc.defaultVal) } return attrs diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 4273b56916..920361a103 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -468,7 +468,7 @@ func (c *usedSpaceService) AnnounceUsedSpace(ctx context.Context, req *container } for _, aV2 := range req.GetBody().GetAnnouncements() { - if err := c.processLoadValue(ctx, *containerSDK.NewAnnouncementFromV2(aV2), passedRoute, w); err != nil { + if err := c.processLoadValue(ctx, *containerSDK.NewAnnouncementFromV2(&aV2), passedRoute, w); err != nil { return nil, err } } diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index a827753e83..ac8879f87c 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -354,7 +354,7 @@ func (n *netInfo) Dump(ver *refs.Version) (*netmapV2.NetworkInfo, error) { } var ( - ps []*netmapV2.NetworkParameter + ps []netmapV2.NetworkParameter netCfg netmapV2.NetworkConfig ) @@ -364,7 +364,7 @@ func (n *netInfo) Dump(ver *refs.Version) (*netmapV2.NetworkInfo, error) { p.SetKey(key) p.SetValue(value) - ps = append(ps, &p) + ps = append(ps, p) return nil }); err != nil { diff --git a/cmd/neofs-node/reputation.go b/cmd/neofs-node/reputation.go index af101ac3f4..7002e8c1c3 100644 --- a/cmd/neofs-node/reputation.go +++ b/cmd/neofs-node/reputation.go @@ -260,7 +260,7 @@ func (s *reputationServer) AnnounceLocalTrust(ctx context.Context, req *v2reputa } for _, trust := range body.GetTrusts() { - err = s.processLocalTrust(body.GetEpoch(), apiToLocalTrust(trust, passedRoute[0].PublicKey()), passedRoute, w) + err = s.processLocalTrust(body.GetEpoch(), apiToLocalTrust(&trust, passedRoute[0].PublicKey()), passedRoute, w) if err != nil { return nil, fmt.Errorf("could not write one of local trusts: %w", err) } diff --git a/pkg/core/container/fmt_test.go b/pkg/core/container/fmt_test.go index 7800990cad..4c65b0f15d 100644 --- a/pkg/core/container/fmt_test.go +++ b/pkg/core/container/fmt_test.go @@ -42,7 +42,7 @@ func TestCheckFormat(t *testing.T) { require.NoError(t, CheckFormat(c)) // set empty value attribute - attr1 := container.NewAttribute() + var attr1 container.Attribute attr1.SetKey("attr") attrs := container.Attributes{attr1} @@ -51,11 +51,11 @@ func TestCheckFormat(t *testing.T) { require.ErrorIs(t, CheckFormat(c), errEmptyAttribute) // add same key attribute - attr2 := container.NewAttribute() + var attr2 container.Attribute attr2.SetKey(attr1.Key()) attr2.SetValue("val") - attr1.SetValue(attr2.Value()) + attrs[0].SetValue(attr2.Value()) attrs = append(attrs, attr2) @@ -63,7 +63,9 @@ func TestCheckFormat(t *testing.T) { require.ErrorIs(t, CheckFormat(c), errRepeatedAttributes) - attr2.SetKey(attr1.Key() + "smth") + attrs[1].SetKey(attr1.Key() + "smth") + + c.SetAttributes(attrs) require.NoError(t, CheckFormat(c)) } diff --git a/pkg/core/object/fmt_test.go b/pkg/core/object/fmt_test.go index 14e58452bc..b64a0ecbf6 100644 --- a/pkg/core/object/fmt_test.go +++ b/pkg/core/object/fmt_test.go @@ -119,7 +119,7 @@ func TestFormatValidator_Validate(t *testing.T) { require.Error(t, v.ValidateContent(obj)) // no tombstone content content := object.NewTombstone() - content.SetMembers([]*oidSDK.ID{nil}) + content.SetMembers([]oidSDK.ID{*testObjectID(t)}) data, err := content.Marshal() require.NoError(t, err) @@ -128,7 +128,7 @@ func TestFormatValidator_Validate(t *testing.T) { require.Error(t, v.ValidateContent(obj)) // no members in tombstone - content.SetMembers([]*oidSDK.ID{testObjectID(t)}) + content.SetMembers([]oidSDK.ID{*testObjectID(t)}) data, err = content.Marshal() require.NoError(t, err) @@ -137,7 +137,7 @@ func TestFormatValidator_Validate(t *testing.T) { require.Error(t, v.ValidateContent(obj)) // no expiration epoch in tombstone - expirationAttribute := object.NewAttribute() + var expirationAttribute object.Attribute expirationAttribute.SetKey(objectV2.SysAttributeExpEpoch) expirationAttribute.SetValue(strconv.Itoa(10)) @@ -161,7 +161,7 @@ func TestFormatValidator_Validate(t *testing.T) { require.Error(t, v.ValidateContent(obj)) content := storagegroup.New() - content.SetMembers([]*oidSDK.ID{nil}) + content.SetMembers([]oidSDK.ID{}) data, err := content.Marshal() require.NoError(t, err) @@ -170,7 +170,7 @@ func TestFormatValidator_Validate(t *testing.T) { require.Error(t, v.ValidateContent(obj)) - content.SetMembers([]*oidSDK.ID{testObjectID(t)}) + content.SetMembers([]oidSDK.ID{*testObjectID(t)}) data, err = content.Marshal() require.NoError(t, err) @@ -184,7 +184,7 @@ func TestFormatValidator_Validate(t *testing.T) { fn := func(val string) *object.Object { obj := blankValidObject(&ownerKey.PrivateKey) - a := object.NewAttribute() + var a object.Attribute a.SetKey(objectV2.SysAttributeExpEpoch) a.SetValue(val) @@ -218,11 +218,11 @@ func TestFormatValidator_Validate(t *testing.T) { t.Run("duplication", func(t *testing.T) { obj := blankValidObject(&ownerKey.PrivateKey) - a1 := object.NewAttribute() + var a1 object.Attribute a1.SetKey("key1") a1.SetValue("val1") - a2 := object.NewAttribute() + var a2 object.Attribute a2.SetKey("key2") a2.SetValue("val2") @@ -232,6 +232,7 @@ func TestFormatValidator_Validate(t *testing.T) { require.NoError(t, err) a2.SetKey(a1.Key()) + obj.SetAttributes(a1, a2) err = v.checkAttributes(obj) require.Equal(t, errDuplAttr, err) @@ -240,7 +241,7 @@ func TestFormatValidator_Validate(t *testing.T) { t.Run("empty value", func(t *testing.T) { obj := blankValidObject(&ownerKey.PrivateKey) - a := object.NewAttribute() + var a object.Attribute a.SetKey("key") obj.SetAttributes(a) diff --git a/pkg/local_object_storage/blobstor/blobstor_test.go b/pkg/local_object_storage/blobstor/blobstor_test.go index e2d54975f2..fe7b4f3520 100644 --- a/pkg/local_object_storage/blobstor/blobstor_test.go +++ b/pkg/local_object_storage/blobstor/blobstor_test.go @@ -98,7 +98,7 @@ func TestBlobstor_needsCompression(t *testing.T) { newObjectWithCt := func(contentType string) *objectSDK.Object { obj := testObject(smallSizeLimit + 1) if contentType != "" { - a := objectSDK.NewAttribute() + var a objectSDK.Attribute a.SetKey(objectSDK.AttributeContentType) a.SetValue(contentType) obj.SetAttributes(a) diff --git a/pkg/local_object_storage/engine/engine_test.go b/pkg/local_object_storage/engine/engine_test.go index 4f045ac878..7a0b22f9c1 100644 --- a/pkg/local_object_storage/engine/engine_test.go +++ b/pkg/local_object_storage/engine/engine_test.go @@ -171,7 +171,7 @@ func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object { } func addAttribute(obj *object.Object, key, val string) { - attr := object.NewAttribute() + var attr object.Attribute attr.SetKey(key) attr.SetValue(val) diff --git a/pkg/local_object_storage/engine/head_test.go b/pkg/local_object_storage/engine/head_test.go index b754d76d95..e5f040f302 100644 --- a/pkg/local_object_storage/engine/head_test.go +++ b/pkg/local_object_storage/engine/head_test.go @@ -32,7 +32,7 @@ func TestHeadRaw(t *testing.T) { link := generateObjectWithCID(t, cid) link.SetParent(parent) link.SetParentID(parent.ID()) - link.SetChildren(child.ID()) + link.SetChildren(*child.ID()) link.SetSplitID(splitID) t.Run("virtual object split in different shards", func(t *testing.T) { diff --git a/pkg/local_object_storage/engine/inhume_test.go b/pkg/local_object_storage/engine/inhume_test.go index f3626c3b7a..16f6956972 100644 --- a/pkg/local_object_storage/engine/inhume_test.go +++ b/pkg/local_object_storage/engine/inhume_test.go @@ -31,7 +31,7 @@ func TestStorageEngine_Inhume(t *testing.T) { link := generateObjectWithCID(t, cid) link.SetParent(parent) link.SetParentID(parent.ID()) - link.SetChildren(child.ID()) + link.SetChildren(*child.ID()) link.SetSplitID(splitID) t.Run("delete small object", func(t *testing.T) { diff --git a/pkg/local_object_storage/engine/lock_test.go b/pkg/local_object_storage/engine/lock_test.go index ee3b4da1ab..d1261d3a49 100644 --- a/pkg/local_object_storage/engine/lock_test.go +++ b/pkg/local_object_storage/engine/lock_test.go @@ -102,7 +102,7 @@ func TestLockUserScenario(t *testing.T) { tombObj := generateObjectWithCID(t, cnr) tombObj.SetType(object.TypeTombstone) tombObj.SetID(tombForLockID) - tombObj.SetAttributes(&a) + tombObj.SetAttributes(a) err = Put(e, tombObj) require.NoError(t, err) @@ -171,7 +171,7 @@ func TestLockExpiration(t *testing.T) { lock := generateObjectWithCID(t, cnr) lock.SetType(object.TypeLock) - lock.SetAttributes(&a) + lock.SetAttributes(a) err = Put(e, lock) require.NoError(t, err) diff --git a/pkg/local_object_storage/metabase/db_test.go b/pkg/local_object_storage/metabase/db_test.go index 020dc8c189..0712267b7d 100644 --- a/pkg/local_object_storage/metabase/db_test.go +++ b/pkg/local_object_storage/metabase/db_test.go @@ -97,7 +97,7 @@ func generateAddress() *addressSDK.Address { } func addAttribute(obj *object.Object, key, val string) { - attr := object.NewAttribute() + var attr object.Attribute attr.SetKey(key) attr.SetValue(val) diff --git a/pkg/local_object_storage/metabase/exists_test.go b/pkg/local_object_storage/metabase/exists_test.go index 00a018310e..6737812bda 100644 --- a/pkg/local_object_storage/metabase/exists_test.go +++ b/pkg/local_object_storage/metabase/exists_test.go @@ -99,7 +99,7 @@ func TestDB_Exists(t *testing.T) { link := generateObjectWithCID(t, cid) link.SetParent(parent) link.SetParentID(parent.ID()) - link.SetChildren(child.ID()) + link.SetChildren(*child.ID()) link.SetSplitID(splitID) t.Run("direct order", func(t *testing.T) { diff --git a/pkg/local_object_storage/metabase/select_test.go b/pkg/local_object_storage/metabase/select_test.go index d479a3255b..618149f252 100644 --- a/pkg/local_object_storage/metabase/select_test.go +++ b/pkg/local_object_storage/metabase/select_test.go @@ -178,7 +178,7 @@ func TestDB_SelectRootPhyParent(t *testing.T) { link := generateObjectWithCID(t, cid) link.SetParent(parent) link.SetParentID(parent.ID()) - link.SetChildren(leftChild.ID(), rightChild.ID()) + link.SetChildren(*leftChild.ID(), *rightChild.ID()) err = putBig(db, link) require.NoError(t, err) diff --git a/pkg/local_object_storage/shard/control_test.go b/pkg/local_object_storage/shard/control_test.go index 683795abe5..d0cad7963b 100644 --- a/pkg/local_object_storage/shard/control_test.go +++ b/pkg/local_object_storage/shard/control_test.go @@ -71,9 +71,10 @@ func TestRefillMetabase(t *testing.T) { tombMembers := make([]*addressSDK.Address, 0, len(tombstone.Members())) - for _, member := range tombstone.Members() { + members := tombstone.Members() + for i := range tombstone.Members() { a := addressSDK.NewAddress() - a.SetObjectID(member) + a.SetObjectID(&members[i]) a.SetContainerID(tombObj.ContainerID()) tombMembers = append(tombMembers, a) diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index f1aa5e29a3..634e89da0e 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -105,7 +105,7 @@ func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object { } func addAttribute(obj *object.Object, key, val string) { - attr := object.NewAttribute() + var attr object.Attribute attr.SetKey(key) attr.SetValue(val) diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index 0a9d3840a2..be867de4e3 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -126,9 +126,9 @@ func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBod return nil, err } - cidList := make([]*refs.ContainerID, 0, len(cnrs)) + cidList := make([]refs.ContainerID, len(cnrs)) for i := range cnrs { - cidList = append(cidList, cnrs[i].ToV2()) + cidList[i] = *cnrs[i].ToV2() } res := new(container.ListResponseBody) diff --git a/pkg/services/object/acl/eacl/v2/eacl_test.go b/pkg/services/object/acl/eacl/v2/eacl_test.go index 12d2e29974..99cc190dfc 100644 --- a/pkg/services/object/acl/eacl/v2/eacl_test.go +++ b/pkg/services/object/acl/eacl/v2/eacl_test.go @@ -51,15 +51,12 @@ func testAddress(t *testing.T) *objectSDKAddress.Address { return addr } -func testXHeaders(strs ...string) []*session.XHeader { - res := make([]*session.XHeader, 0, len(strs)/2) +func testXHeaders(strs ...string) []session.XHeader { + res := make([]session.XHeader, len(strs)/2) for i := 0; i < len(strs); i += 2 { - x := new(session.XHeader) - x.SetKey(strs[i]) - x.SetValue(strs[i+1]) - - res = append(res, x) + res[i/2].SetKey(strs[i]) + res[i/2].SetValue(strs[i+1]) } return res @@ -89,7 +86,7 @@ func TestHeadRequest(t *testing.T) { attrKey := "attr_key" attrVal := "attr_val" - attr := object.NewAttribute() + var attr object.Attribute attr.SetKey(attrKey) attr.SetValue(attrVal) obj.SetAttributes(attr) @@ -138,7 +135,7 @@ func TestHeadRequest(t *testing.T) { meta.SetXHeaders(xHdrs) - obj.SetAttributes(nil) + obj.SetAttributes() require.Equal(t, eaclSDK.ActionAllow, validator.CalculateAction(unit)) } diff --git a/pkg/services/object/acl/eacl/v2/headers.go b/pkg/services/object/acl/eacl/v2/headers.go index 8aaedaa673..265306dc50 100644 --- a/pkg/services/object/acl/eacl/v2/headers.go +++ b/pkg/services/object/acl/eacl/v2/headers.go @@ -75,7 +75,7 @@ func requestHeaders(msg xHeaderSource) []eaclSDK.Header { res := make([]eaclSDK.Header, 0, len(xHdrs)) for i := range xHdrs { - res = append(res, sessionSDK.NewXHeaderFromV2(xHdrs[i])) + res = append(res, sessionSDK.NewXHeaderFromV2(&xHdrs[i])) } return res diff --git a/pkg/services/object/acl/eacl/v2/object.go b/pkg/services/object/acl/eacl/v2/object.go index 243514fc25..4d3daad076 100644 --- a/pkg/services/object/acl/eacl/v2/object.go +++ b/pkg/services/object/acl/eacl/v2/object.go @@ -90,7 +90,7 @@ func headersFromObject(obj *object.Object, addr *objectSDKAddress.Address) []eac attrs := obj.Attributes() for i := range attrs { - res = append(res, attrs[i]) + res = append(res, &attrs[i]) // only pointer attrs can implement eaclSDK.Header interface } } diff --git a/pkg/services/object/acl/eacl/v2/xheader.go b/pkg/services/object/acl/eacl/v2/xheader.go index a0874b42eb..8991f2b3ec 100644 --- a/pkg/services/object/acl/eacl/v2/xheader.go +++ b/pkg/services/object/acl/eacl/v2/xheader.go @@ -5,7 +5,7 @@ import ( ) type xHeaderSource interface { - GetXHeaders() []*session.XHeader + GetXHeaders() []session.XHeader } type requestXHeaderSource struct { @@ -18,9 +18,9 @@ type responseXHeaderSource struct { req Request } -func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader { +func (s *requestXHeaderSource) GetXHeaders() []session.XHeader { ln := 0 - xHdrs := make([][]*session.XHeader, 0) + xHdrs := make([][]session.XHeader, 0) for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() { x := meta.GetXHeaders() @@ -30,7 +30,7 @@ func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader { xHdrs = append(xHdrs, x) } - res := make([]*session.XHeader, 0, ln) + res := make([]session.XHeader, 0, ln) for i := range xHdrs { for j := range xHdrs[i] { @@ -41,9 +41,9 @@ func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader { return res } -func (s *responseXHeaderSource) GetXHeaders() []*session.XHeader { +func (s *responseXHeaderSource) GetXHeaders() []session.XHeader { ln := 0 - xHdrs := make([][]*session.XHeader, 0) + xHdrs := make([][]session.XHeader, 0) for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() { x := meta.GetXHeaders() @@ -53,7 +53,7 @@ func (s *responseXHeaderSource) GetXHeaders() []*session.XHeader { xHdrs = append(xHdrs, x) } - res := make([]*session.XHeader, 0, ln) + res := make([]session.XHeader, 0, ln) for i := range xHdrs { for j := range xHdrs[i] { diff --git a/pkg/services/object/delete/exec.go b/pkg/services/object/delete/exec.go index e712bb8768..5c9c608f64 100644 --- a/pkg/services/object/delete/exec.go +++ b/pkg/services/object/delete/exec.go @@ -124,13 +124,13 @@ func (exec *execCtx) collectMembers() (ok bool) { func (exec *execCtx) collectChain() bool { var ( err error - chain []*oidSDK.ID + chain []oidSDK.ID ) exec.log.Debug("assembling chain...") for prev := exec.splitInfo.LastPart(); prev != nil; { - chain = append(chain, prev) + chain = append(chain, *prev) prev, err = exec.svc.header.previous(exec, prev) switch { @@ -174,7 +174,7 @@ func (exec *execCtx) collectChildren() bool { exec.status = statusOK exec.err = nil - exec.addMembers(append(children, exec.splitInfo.Link())) + exec.addMembers(append(children, *exec.splitInfo.Link())) return true } @@ -205,12 +205,12 @@ func (exec *execCtx) supplementBySplitID() bool { } } -func (exec *execCtx) addMembers(incoming []*oidSDK.ID) { +func (exec *execCtx) addMembers(incoming []oidSDK.ID) { members := exec.tombstone.Members() for i := range members { for j := 0; j < len(incoming); j++ { // don't use range, slice mutates in body - if members[i].Equal(incoming[j]) { + if members[i].Equal(&incoming[j]) { incoming = append(incoming[:j], incoming[j+1:]...) j-- } @@ -245,7 +245,7 @@ func (exec *execCtx) initTombstoneObject() bool { exec.tombstoneObj.SetType(object.TypeTombstone) exec.tombstoneObj.SetPayload(payload) - a := object.NewAttribute() + var a object.Attribute a.SetKey(objectV2.SysAttributeExpEpoch) a.SetValue(strconv.FormatUint(exec.tombstone.ExpirationEpoch(), 10)) diff --git a/pkg/services/object/delete/local.go b/pkg/services/object/delete/local.go index 7ec59456df..d55ac7d579 100644 --- a/pkg/services/object/delete/local.go +++ b/pkg/services/object/delete/local.go @@ -36,7 +36,7 @@ func (exec *execCtx) formTombstone() (ok bool) { exec.tombstone.SetExpirationEpoch( exec.svc.netInfo.CurrentEpoch() + tsLifetime, ) - exec.addMembers([]*oidSDK.ID{exec.address().ObjectID()}) + exec.addMembers([]oidSDK.ID{*exec.address().ObjectID()}) exec.log.Debug("forming split info...") diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index ef0e2c1e69..2a711bb3b9 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -40,14 +40,14 @@ type cfg struct { // must return (nil, nil) for PHY objects splitInfo(*execCtx) (*object.SplitInfo, error) - children(*execCtx) ([]*oidSDK.ID, error) + children(*execCtx) ([]oidSDK.ID, error) // must return (nil, nil) for 1st object in chain previous(*execCtx, *oidSDK.ID) (*oidSDK.ID, error) } searcher interface { - splitMembers(*execCtx) ([]*oidSDK.ID, error) + splitMembers(*execCtx) ([]oidSDK.ID, error) } placer interface { diff --git a/pkg/services/object/delete/util.go b/pkg/services/object/delete/util.go index a8944d0a4b..9b1a108a1e 100644 --- a/pkg/services/object/delete/util.go +++ b/pkg/services/object/delete/util.go @@ -18,7 +18,7 @@ type searchSvcWrapper searchsvc.Service type putSvcWrapper putsvc.Service type simpleIDWriter struct { - ids []*oidSDK.ID + ids []oidSDK.ID } func (w *headSvcWrapper) headAddress(exec *execCtx, addr *addressSDK.Address) (*object.Object, error) { @@ -53,7 +53,7 @@ func (w *headSvcWrapper) splitInfo(exec *execCtx) (*object.SplitInfo, error) { } } -func (w *headSvcWrapper) children(exec *execCtx) ([]*oidSDK.ID, error) { +func (w *headSvcWrapper) children(exec *execCtx) ([]oidSDK.ID, error) { a := exec.newAddress(exec.splitInfo.Link()) linking, err := w.headAddress(exec, a) @@ -75,7 +75,7 @@ func (w *headSvcWrapper) previous(exec *execCtx, id *oidSDK.ID) (*oidSDK.ID, err return h.PreviousID(), nil } -func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]*oidSDK.ID, error) { +func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]oidSDK.ID, error) { fs := object.SearchFilters{} fs.AddSplitIDFilter(object.MatchStringEqual, exec.splitInfo.SplitID()) @@ -95,7 +95,7 @@ func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]*oidSDK.ID, error) { return wr.ids, nil } -func (s *simpleIDWriter) WriteIDs(ids []*oidSDK.ID) error { +func (s *simpleIDWriter) WriteIDs(ids []oidSDK.ID) error { s.ids = append(s.ids, ids...) return nil diff --git a/pkg/services/object/get/assemble.go b/pkg/services/object/get/assemble.go index edc0362167..61ce959503 100644 --- a/pkg/services/object/get/assemble.go +++ b/pkg/services/object/get/assemble.go @@ -40,7 +40,7 @@ func (exec *execCtx) assemble() { // * if size > MAX => go right-to-left with HEAD and back with GET // * else go right-to-left with GET and compose in single object before writing - if ok := exec.overtakePayloadInReverse(children[len(children)-1]); ok { + if ok := exec.overtakePayloadInReverse(&children[len(children)-1]); ok { // payload of all children except the last are written, write last payload exec.writeObjectPayload(exec.collectedObject) } @@ -61,7 +61,7 @@ func (exec *execCtx) assemble() { } } -func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []*oidSDK.ID) { +func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []oidSDK.ID) { log := exec.log.With(zap.Stringer("child ID", id)) log.Debug("starting assembling from child") @@ -120,16 +120,16 @@ func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []* return child.PreviousID(), child.Children() } -func (exec *execCtx) overtakePayloadDirectly(children []*oidSDK.ID, rngs []*objectSDK.Range, checkRight bool) { +func (exec *execCtx) overtakePayloadDirectly(children []oidSDK.ID, rngs []objectSDK.Range, checkRight bool) { withRng := len(rngs) > 0 && exec.ctxRange() != nil for i := range children { var r *objectSDK.Range if withRng { - r = rngs[i] + r = &rngs[i] } - child, ok := exec.getChild(children[i], r, !withRng && checkRight) + child, ok := exec.getChild(&children[i], r, !withRng && checkRight) if !ok { return } @@ -165,10 +165,10 @@ func (exec *execCtx) overtakePayloadInReverse(prev *oidSDK.ID) bool { return exec.status == statusOK } -func (exec *execCtx) buildChainInReverse(prev *oidSDK.ID) ([]*oidSDK.ID, []*objectSDK.Range, bool) { +func (exec *execCtx) buildChainInReverse(prev *oidSDK.ID) ([]oidSDK.ID, []objectSDK.Range, bool) { var ( - chain = make([]*oidSDK.ID, 0) - rngs = make([]*objectSDK.Range, 0) + chain = make([]oidSDK.ID, 0) + rngs = make([]objectSDK.Range, 0) seekRng = exec.ctxRange() from = seekRng.GetOffset() to = from + seekRng.GetLength() @@ -201,15 +201,15 @@ func (exec *execCtx) buildChainInReverse(prev *oidSDK.ID) ([]*oidSDK.ID, []*obje sz = to - off - exec.curOff } - r := objectSDK.NewRange() - r.SetOffset(off) - r.SetLength(sz) + index := len(rngs) + rngs = append(rngs, objectSDK.Range{}) + rngs[index].SetOffset(off) + rngs[index].SetLength(sz) - rngs = append(rngs, r) - chain = append(chain, head.ID()) + chain = append(chain, *head.ID()) } } else { - chain = append(chain, head.ID()) + chain = append(chain, *head.ID()) } prev = head.PreviousID() diff --git a/pkg/services/object/get/get.go b/pkg/services/object/get/get.go index f1b1626c9a..9b65fbf3cf 100644 --- a/pkg/services/object/get/get.go +++ b/pkg/services/object/get/get.go @@ -37,7 +37,7 @@ func (s *Service) GetRangeHash(ctx context.Context, prm RangeHashPrm) (*RangeHas commonPrm: prm.commonPrm, } - rngPrm.SetRange(rng) + rngPrm.SetRange(&rng) rngPrm.SetChunkWriter(&hasherWrapper{ hash: util.NewSaltingWriter(h, prm.salt), }) diff --git a/pkg/services/object/get/get_test.go b/pkg/services/object/get/get_test.go index ffc7860261..9608df8f81 100644 --- a/pkg/services/object/get/get_test.go +++ b/pkg/services/object/get/get_test.go @@ -194,7 +194,7 @@ func generateAddress() *addressSDK.Address { return addr } -func generateObject(addr *addressSDK.Address, prev *oidSDK.ID, payload []byte, children ...*oidSDK.ID) *objectSDK.Object { +func generateObject(addr *addressSDK.Address, prev *oidSDK.ID, payload []byte, children ...oidSDK.ID) *objectSDK.Object { obj := objectSDK.New() obj.SetContainerID(addr.ContainerID()) obj.SetID(addr.ObjectID()) @@ -427,7 +427,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) { return mNodes, mAddr } -func generateChain(ln int, cid *cid.ID) ([]*objectSDK.Object, []*oidSDK.ID, []byte) { +func generateChain(ln int, cid *cid.ID) ([]*objectSDK.Object, []oidSDK.ID, []byte) { curID := generateID() var prevID *oidSDK.ID @@ -435,11 +435,11 @@ func generateChain(ln int, cid *cid.ID) ([]*objectSDK.Object, []*oidSDK.ID, []by addr.SetContainerID(cid) res := make([]*objectSDK.Object, 0, ln) - ids := make([]*oidSDK.ID, 0, ln) + ids := make([]oidSDK.ID, 0, ln) payload := make([]byte, 0, ln*10) for i := 0; i < ln; i++ { - ids = append(ids, curID) + ids = append(ids, *curID) addr.SetObjectID(curID) payloadPart := make([]byte, 10) @@ -760,11 +760,11 @@ func TestGetRemoteSmall(t *testing.T) { child1Addr := addressSDK.NewAddress() child1Addr.SetContainerID(cid) - child1Addr.SetObjectID(childIDs[0]) + child1Addr.SetObjectID(&childIDs[0]) child2Addr := addressSDK.NewAddress() child2Addr.SetContainerID(cid) - child2Addr.SetObjectID(childIDs[1]) + child2Addr.SetObjectID(&childIDs[1]) c1 := newTestClient() c1.addResult(addr, nil, errors.New("any error")) @@ -836,11 +836,11 @@ func TestGetRemoteSmall(t *testing.T) { child1Addr := addressSDK.NewAddress() child1Addr.SetContainerID(cid) - child1Addr.SetObjectID(childIDs[0]) + child1Addr.SetObjectID(&childIDs[0]) child2Addr := addressSDK.NewAddress() child2Addr.SetContainerID(cid) - child2Addr.SetObjectID(childIDs[1]) + child2Addr.SetObjectID(&childIDs[1]) c1 := newTestClient() c1.addResult(addr, nil, errors.New("any error")) diff --git a/pkg/services/object/get/prm.go b/pkg/services/object/get/prm.go index ab36726d5b..686adb293f 100644 --- a/pkg/services/object/get/prm.go +++ b/pkg/services/object/get/prm.go @@ -27,7 +27,7 @@ type RangeHashPrm struct { hashGen func() hash.Hash - rngs []*object.Range + rngs []object.Range salt []byte } @@ -87,7 +87,7 @@ func (p *RangePrm) SetRange(rng *object.Range) { } // SetRangeList sets list of object payload ranges. -func (p *RangeHashPrm) SetRangeList(rngs []*object.Range) { +func (p *RangeHashPrm) SetRangeList(rngs []object.Range) { p.rngs = rngs } diff --git a/pkg/services/object/get/v2/util.go b/pkg/services/object/get/v2/util.go index 36fa1e4370..386a1b9b8b 100644 --- a/pkg/services/object/get/v2/util.go +++ b/pkg/services/object/get/v2/util.go @@ -275,10 +275,10 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran p.WithAddress(addressSDK.NewAddressFromV2(body.GetAddress())) rngsV2 := body.GetRanges() - rngs := make([]*object.Range, 0, len(rngsV2)) + rngs := make([]object.Range, len(rngsV2)) for i := range rngsV2 { - rngs = append(rngs, object.NewRangeFromV2(rngsV2[i])) + rngs[i] = *object.NewRangeFromV2(&rngsV2[i]) } p.SetRangeList(rngs) diff --git a/pkg/services/object/internal/client/client.go b/pkg/services/object/internal/client/client.go index a60c503ba1..494c4733d6 100644 --- a/pkg/services/object/internal/client/client.go +++ b/pkg/services/object/internal/client/client.go @@ -474,11 +474,11 @@ func (x *SearchObjectsPrm) SetFilters(fs object.SearchFilters) { // SearchObjectsRes groups resulting values of SearchObjects operation. type SearchObjectsRes struct { - ids []*oidSDK.ID + ids []oidSDK.ID } // IDList returns identifiers of the matched objects. -func (x SearchObjectsRes) IDList() []*oidSDK.ID { +func (x SearchObjectsRes) IDList() []oidSDK.ID { return x.ids } @@ -510,7 +510,7 @@ func SearchObjects(prm SearchObjectsPrm) (*SearchObjectsRes, error) { } buf := make([]oidSDK.ID, 10) - var ids []*oidSDK.ID + var ids []oidSDK.ID var n int var ok bool @@ -519,7 +519,7 @@ func SearchObjects(prm SearchObjectsPrm) (*SearchObjectsRes, error) { if n > 0 { for i := range buf[:n] { v := buf[i] - ids = append(ids, &v) + ids = append(ids, v) } } diff --git a/pkg/services/object/search/exec.go b/pkg/services/object/search/exec.go index e19ccca9ad..2d7d17ce47 100644 --- a/pkg/services/object/search/exec.go +++ b/pkg/services/object/search/exec.go @@ -133,7 +133,7 @@ func (exec execCtx) remoteClient(info client.NodeInfo) (searchClient, bool) { return nil, false } -func (exec *execCtx) writeIDList(ids []*oidSDK.ID) { +func (exec *execCtx) writeIDList(ids []oidSDK.ID) { err := exec.prm.writer.WriteIDs(ids) switch { diff --git a/pkg/services/object/search/prm.go b/pkg/services/object/search/prm.go index 7459c5247a..59ea82f4de 100644 --- a/pkg/services/object/search/prm.go +++ b/pkg/services/object/search/prm.go @@ -24,12 +24,12 @@ type Prm struct { // IDListWriter is an interface of target component // to write list of object identifiers. type IDListWriter interface { - WriteIDs([]*oidSDK.ID) error + WriteIDs([]oidSDK.ID) error } // RequestForwarder is a callback for forwarding of the // original Search requests. -type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]*oidSDK.ID, error) +type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]oidSDK.ID, error) // SetCommonParameters sets common parameters of the operation. func (p *Prm) SetCommonParameters(common *util.CommonPrm) { diff --git a/pkg/services/object/search/search_test.go b/pkg/services/object/search/search_test.go index 1c1153d96b..28beb0727b 100644 --- a/pkg/services/object/search/search_test.go +++ b/pkg/services/object/search/search_test.go @@ -24,7 +24,7 @@ import ( ) type idsErr struct { - ids []*oidSDK.ID + ids []oidSDK.ID err error } @@ -46,7 +46,7 @@ type testClientCache struct { } type simpleIDWriter struct { - ids []*oidSDK.ID + ids []oidSDK.ID } type testEpochReceiver uint64 @@ -55,7 +55,7 @@ func (e testEpochReceiver) currentEpoch() (uint64, error) { return uint64(e), nil } -func (s *simpleIDWriter) WriteIDs(ids []*oidSDK.ID) error { +func (s *simpleIDWriter) WriteIDs(ids []oidSDK.ID) error { s.ids = append(s.ids, ids...) return nil } @@ -95,7 +95,7 @@ func (c *testClientCache) get(info clientcore.NodeInfo) (searchClient, error) { return v, nil } -func (s *testStorage) search(exec *execCtx) ([]*oidSDK.ID, error) { +func (s *testStorage) search(exec *execCtx) ([]oidSDK.ID, error) { v, ok := s.items[exec.containerID().String()] if !ok { return nil, nil @@ -104,7 +104,7 @@ func (s *testStorage) search(exec *execCtx) ([]*oidSDK.ID, error) { return v.ids, v.err } -func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]*oidSDK.ID, error) { +func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]oidSDK.ID, error) { v, ok := c.items[exec.containerID().String()] if !ok { return nil, nil @@ -113,7 +113,7 @@ func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]*oi return v.ids, v.err } -func (c *testStorage) addResult(addr *cid.ID, ids []*oidSDK.ID, err error) { +func (c *testStorage) addResult(addr *cid.ID, ids []oidSDK.ID, err error) { c.items[addr.String()] = idsErr{ ids: ids, err: err, @@ -125,11 +125,10 @@ func testSHA256() (cs [sha256.Size]byte) { return cs } -func generateIDs(num int) []*oidSDK.ID { - res := make([]*oidSDK.ID, num) +func generateIDs(num int) []oidSDK.ID { + res := make([]oidSDK.ID, num) for i := 0; i < num; i++ { - res[i] = oidSDK.NewID() res[i].SetSHA256(testSHA256()) } @@ -227,12 +226,9 @@ func TestGetRemoteSmall(t *testing.T) { placementDim := []int{2} - rs := make([]*netmap.Replica, 0, len(placementDim)) + rs := make([]netmap.Replica, len(placementDim)) for i := range placementDim { - r := netmap.NewReplica() - r.SetCount(uint32(placementDim[i])) - - rs = append(rs, r) + rs[i].SetCount(uint32(placementDim[i])) } pp := netmap.NewPlacementPolicy() @@ -315,13 +311,10 @@ func TestGetFromPastEpoch(t *testing.T) { placementDim := []int{2, 2} - rs := make([]*netmap.Replica, 0, len(placementDim)) + rs := make([]netmap.Replica, len(placementDim)) for i := range placementDim { - r := netmap.NewReplica() - r.SetCount(uint32(placementDim[i])) - - rs = append(rs, r) + rs[i].SetCount(uint32(placementDim[i])) } pp := netmap.NewPlacementPolicy() @@ -393,7 +386,7 @@ func TestGetFromPastEpoch(t *testing.T) { commonPrm := new(util.CommonPrm) p.SetCommonParameters(commonPrm) - assertContains := func(idsList ...[]*oidSDK.ID) { + assertContains := func(idsList ...[]oidSDK.ID) { var sz int for _, ids := range idsList { diff --git a/pkg/services/object/search/service.go b/pkg/services/object/search/service.go index c20135ab4f..9aa8993d1a 100644 --- a/pkg/services/object/search/service.go +++ b/pkg/services/object/search/service.go @@ -25,7 +25,7 @@ type Service struct { type Option func(*cfg) type searchClient interface { - searchObjects(*execCtx, client.NodeInfo) ([]*oidSDK.ID, error) + searchObjects(*execCtx, client.NodeInfo) ([]oidSDK.ID, error) } type ClientConstructor interface { @@ -36,7 +36,7 @@ type cfg struct { log *logger.Logger localStorage interface { - search(*execCtx) ([]*oidSDK.ID, error) + search(*execCtx) ([]oidSDK.ID, error) } clientConstructor interface { diff --git a/pkg/services/object/search/util.go b/pkg/services/object/search/util.go index ee9a0d16cd..0dc2347bb4 100644 --- a/pkg/services/object/search/util.go +++ b/pkg/services/object/search/util.go @@ -45,7 +45,7 @@ func newUniqueAddressWriter(w IDListWriter) IDListWriter { } } -func (w *uniqueIDWriter) WriteIDs(list []*oidSDK.ID) error { +func (w *uniqueIDWriter) WriteIDs(list []oidSDK.ID) error { w.mtx.Lock() for i := 0; i < len(list); i++ { // don't use range, slice mutates in body @@ -80,7 +80,7 @@ func (c *clientConstructorWrapper) get(info client.NodeInfo) (searchClient, erro }, nil } -func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]*oidSDK.ID, error) { +func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]oidSDK.ID, error) { if exec.prm.forwarder != nil { return exec.prm.forwarder(info, c.client) } @@ -111,7 +111,7 @@ func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]*o return res.IDList(), nil } -func (e *storageEngineWrapper) search(exec *execCtx) ([]*oidSDK.ID, error) { +func (e *storageEngineWrapper) search(exec *execCtx) ([]oidSDK.ID, error) { r, err := (*engine.StorageEngine)(e).Select(new(engine.SelectPrm). WithFilters(exec.searchFilters()). WithContainerID(exec.containerID()), @@ -123,11 +123,11 @@ func (e *storageEngineWrapper) search(exec *execCtx) ([]*oidSDK.ID, error) { return idsFromAddresses(r.AddressList()), nil } -func idsFromAddresses(addrs []*addressSDK.Address) []*oidSDK.ID { - ids := make([]*oidSDK.ID, len(addrs)) +func idsFromAddresses(addrs []*addressSDK.Address) []oidSDK.ID { + ids := make([]oidSDK.ID, len(addrs)) for i := range addrs { - ids[i] = addrs[i].ObjectID() + ids[i] = *addrs[i].ObjectID() } return ids diff --git a/pkg/services/object/search/v2/streamer.go b/pkg/services/object/search/v2/streamer.go index 71a1b261a3..76d180e760 100644 --- a/pkg/services/object/search/v2/streamer.go +++ b/pkg/services/object/search/v2/streamer.go @@ -11,16 +11,16 @@ type streamWriter struct { stream objectSvc.SearchStream } -func (s *streamWriter) WriteIDs(ids []*oidSDK.ID) error { +func (s *streamWriter) WriteIDs(ids []oidSDK.ID) error { r := new(object.SearchResponse) body := new(object.SearchResponseBody) r.SetBody(body) - idsV2 := make([]*refs.ObjectID, len(ids)) + idsV2 := make([]refs.ObjectID, len(ids)) for i := range ids { - idsV2[i] = ids[i].ToV2() + idsV2[i] = *ids[i].ToV2() } body.SetIDList(idsV2) diff --git a/pkg/services/object/search/v2/util.go b/pkg/services/object/search/v2/util.go index f17672957d..650a3af29c 100644 --- a/pkg/services/object/search/v2/util.go +++ b/pkg/services/object/search/v2/util.go @@ -45,7 +45,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre return nil, err } - p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) ([]*oidSDK.ID, error) { + p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) ([]oidSDK.ID, error) { var err error // once compose and resign forwarding request @@ -77,7 +77,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre // code below is copy-pasted from c.SearchObjects implementation, // perhaps it is worth highlighting the utility function in neofs-api-go var ( - searchResult []*oidSDK.ID + searchResult []oidSDK.ID resp = new(objectV2.SearchResponse) ) @@ -104,7 +104,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre chunk := resp.GetBody().GetIDList() for i := range chunk { - searchResult = append(searchResult, oidSDK.NewIDFromV2(chunk[i])) + searchResult = append(searchResult, *oidSDK.NewIDFromV2(&chunk[i])) } } @@ -119,11 +119,11 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre return p, nil } -func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]*oidSDK.ID, error)) searchsvc.RequestForwarder { - return func(info client.NodeInfo, c client.MultiAddressClient) ([]*oidSDK.ID, error) { +func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]oidSDK.ID, error)) searchsvc.RequestForwarder { + return func(info client.NodeInfo, c client.MultiAddressClient) ([]oidSDK.ID, error) { var ( firstErr error - res []*oidSDK.ID + res []oidSDK.ID key = info.PublicKey() ) diff --git a/pkg/services/object_manager/placement/traverser_test.go b/pkg/services/object_manager/placement/traverser_test.go index 2657414a0b..6378a06288 100644 --- a/pkg/services/object_manager/placement/traverser_test.go +++ b/pkg/services/object_manager/placement/traverser_test.go @@ -40,7 +40,7 @@ func copyVectors(v []netmap.Nodes) []netmap.Nodes { func testPlacement(t *testing.T, ss, rs []int) ([]netmap.Nodes, *container.Container) { nodes := make([]netmap.Nodes, 0, len(rs)) - replicas := make([]*netmap.Replica, 0, len(rs)) + replicas := make([]netmap.Replica, 0, len(rs)) num := uint32(0) for i := range ss { @@ -53,7 +53,7 @@ func testPlacement(t *testing.T, ss, rs []int) ([]netmap.Nodes, *container.Conta nodes = append(nodes, netmap.NodesFromInfo(ns)) - s := new(netmap.Replica) + var s netmap.Replica s.SetCount(uint32(rs[i])) replicas = append(replicas, s) diff --git a/pkg/services/object_manager/transformer/transformer.go b/pkg/services/object_manager/transformer/transformer.go index 0a06317bc5..eb3af53ac2 100644 --- a/pkg/services/object_manager/transformer/transformer.go +++ b/pkg/services/object_manager/transformer/transformer.go @@ -23,13 +23,13 @@ type payloadSizeLimiter struct { currentHashers, parentHashers []*payloadChecksumHasher - previous []*oidSDK.ID + previous []oidSDK.ID chunkWriter io.Writer splitID *object.SplitID - parAttrs []*object.Attribute + parAttrs []object.Attribute } type payloadChecksumHasher struct { @@ -79,7 +79,7 @@ func (s *payloadSizeLimiter) initialize() { } // set previous object to the last previous identifier - s.current.SetPreviousID(s.previous[ln-1]) + s.current.SetPreviousID(&s.previous[ln-1]) } s.initializeCurrent() @@ -187,7 +187,7 @@ func (s *payloadSizeLimiter) release(close bool) (*AccessIdentifiers, error) { } // save identifier of the released object - s.previous = append(s.previous, ids.SelfID()) + s.previous = append(s.previous, *ids.SelfID()) if withParent { // generate and release linking object diff --git a/pkg/util/attributes/parser.go b/pkg/util/attributes/parser.go index f188c0f2d2..a3660c62db 100644 --- a/pkg/util/attributes/parser.go +++ b/pkg/util/attributes/parser.go @@ -21,7 +21,7 @@ var ( // ParseV2Attributes parses strings like "K1:V1/K2:V2/K3:V3" into netmap // attributes. Supports escaped symbols "\:", "\/" and "\\". -func ParseV2Attributes(attrs []string, excl []string) ([]*netmap.NodeAttribute, error) { +func ParseV2Attributes(attrs []string, excl []string) ([]netmap.NodeAttribute, error) { restricted := make(map[string]struct{}, len(excl)) for i := range excl { restricted[excl[i]] = struct{}{} @@ -82,7 +82,12 @@ func ParseV2Attributes(attrs []string, excl []string) ([]*netmap.NodeAttribute, } } - return result, nil + nresult := make([]netmap.NodeAttribute, len(result)) + for i := range result { + nresult[i] = *result[i] + } + + return nresult, nil } func replaceEscaping(target string, rollback bool) (s string) {