Add CopyTo method #77

Open
opened 2025-12-28 18:12:28 +00:00 by sami · 0 comments
Owner

Originally created by @smallhive on GitHub (Sep 7, 2023).

In SDK we have task to add CopyTo method for some structures. The method makes a deep copy of the structure.

SDK wraps many api-go structures inside it and modifies them directly. Sometimes we have such situation

// "github.com/nspcc-dev/neofs-api-go/v2/container"
type Container struct {
	v2 container.Container
}

or even such one

// "github.com/nspcc-dev/neofs-api-go/v2/object"
type Object object.Object

Object type is just a synonym for api-go type, but has a lot of methods. Making a deep copy of this type is possible. Although having such CopyTo method in the original api-go type would be very helpful.

Fortunately for this type all internal fields are available via getters/setters and making CopyTo in SDK is just a question of time.

Describe the solution you'd like

Implement CopyTo method directly in api-go repo. Right now in SDK implemented deep copy for the next strcutures:

github.com/nspcc-dev/neofs-api-go/v2/refs

  • refs.ObjectID
  • refs.Signature
  • refs.ContainerID
  • refs.Checksum

github.com/nspcc-dev/neofs-api-go/v2/session

  • session.Token

github.com/nspcc-dev/neofs-api-go/v2/object

  • object.SplitHeader
  • object.Header

github.com/nspcc-dev/neofs-api-go/v2/netmap

  • netmap.Filter
  • netmap.Selector
  • netmap.Replica

Additional context

SDK doesn't mind to share/give/move existing code from it to neo-go repo

Originally created by @smallhive on GitHub (Sep 7, 2023). ## Is your feature request related to a problem? Please describe. In SDK we have [task](https://github.com/nspcc-dev/neofs-sdk-go/issues/194) to add `CopyTo` method for some structures. The method makes a deep copy of the structure. SDK wraps many api-go structures inside it and modifies them directly. Sometimes we have such [situation](https://github.com/nspcc-dev/neofs-sdk-go/blob/62101066229563da2d32565bb37b672c51ec1871/container/container.go#L39) ```go // "github.com/nspcc-dev/neofs-api-go/v2/container" type Container struct { v2 container.Container } ``` or even [such one](https://github.com/nspcc-dev/neofs-sdk-go/blob/62101066229563da2d32565bb37b672c51ec1871/object/object.go#L27) ```go // "github.com/nspcc-dev/neofs-api-go/v2/object" type Object object.Object ``` Object type is just a synonym for api-go type, but has a lot of methods. Making a deep copy of this type is possible. Although having such `CopyTo` method in the original api-go type would be very helpful. Fortunately for this type all internal fields are available via getters/setters and making CopyTo in SDK is just a question of time. ## Describe the solution you'd like Implement `CopyTo` method directly in api-go repo. Right now in SDK implemented deep copy for the next strcutures: github.com/nspcc-dev/neofs-api-go/v2/refs * refs.ObjectID * refs.Signature * refs.ContainerID * refs.Checksum github.com/nspcc-dev/neofs-api-go/v2/session * session.Token github.com/nspcc-dev/neofs-api-go/v2/object * object.SplitHeader * object.Header github.com/nspcc-dev/neofs-api-go/v2/netmap * netmap.Filter * netmap.Selector * netmap.Replica ## Additional context SDK doesn't mind to share/give/move existing code from it to neo-go repo
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-api-go#77
No description provided.