Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

chore: add String() method to IDSlice type #238

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

EclesioMeloJunior
Copy link
Contributor

@EclesioMeloJunior EclesioMeloJunior commented Mar 14, 2022

Description

  • Initialize and preallocate the slice of strings
  • use the method String for each ID and put in the slice
  • return a string of ids separated by ,

Tiny demonstration: https://go.dev/play/p/kd_nd-edWnr

Original suggestion -> ChainSafe/gossamer#2267 (comment)

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? The linked issue doesn't seem to have a lot to do with it. The link is about a race condition, certainly a stringer function can't help with that.

@EclesioMeloJunior
Copy link
Contributor Author

@marten-seemann sorry for the abrupt PR 😅 . I propose these changes, not because of the race condition but from a comment that came up there and I thought that would be ok if IDSlice have a String() method to help with logs, let me know if this is not required

@qdm12
Copy link

qdm12 commented Mar 17, 2022

I proposed to add a String() method forgetting it was from this repository. @EclesioMeloJunior created the PR to add this.

This can be quite nice so we can use i.e. fmt.Sprintf("%s", peer.IDSlice{}) and it would print nicely.

@marten-seemann marten-seemann merged commit 4a03a82 into libp2p:master Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants