Pass user.ID by value in client parameters #190

Closed
opened 2023-11-02 07:50:36 +00:00 by fyrchik · 3 comments

We pass it by pointer to check whether it is set. However, we can check it without pointer -- user.ID embeds a slice which would be nil.
Even if we were to change it to be [25]byte, the first byte is an address prefix and is not zero.
And even if we were to change address prefix, the last 4 bytes are the checksum and won't be 0 for 0 slice.

We pass it by pointer to check whether it is set. However, we can check it without pointer -- user.ID embeds a slice which would be nil. Even if we were to change it to be `[25]byte`, the first byte is an address prefix and is not zero. And even if we were to change address prefix, the last 4 bytes are the checksum and won't be 0 for 0 slice.
fyrchik added the
refactoring
label 2023-11-02 07:50:58 +00:00
Poster
Owner

Refs #121

Refs #121
Collaborator

Let me clarify what is @fyrchik talking about:

Consider PrmContainerList that uses user.ID as pointer. The field cannot have default value and should be set by the client: look at this.

But it is better to introduce a method for user.ID that checks is it empty (cheking []byte slice within) and to make sure that it has been set up by the client to check it with x.Account.Empty() instead cheking for nil

The same is fair for other params which use *user.ID

Let me clarify what is @fyrchik talking about: Consider `PrmContainerList` that uses [user.ID](https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/src/branch/master/client/container_list.go#L22) as pointer. The field cannot have default value and should be set by the client: look at [this](https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/src/branch/master/client/container_list.go#L34). But it is better to introduce a method for `user.ID` that checks is it empty (cheking `[]byte` slice within) and to make sure that it has been set up by the client to check it with `x.Account.Empty()` instead cheking for nil The same is fair for other params which use `*user.ID`
dstepanov-yadro self-assigned this 2023-11-21 08:35:45 +00:00

fixed

fixed
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
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: TrueCloudLab/frostfs-sdk-go#190
There is no content yet.