Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a couple useful methods #102

Merged
merged 3 commits into from May 1, 2020

Conversation

whyrusleeping
Copy link
Member

No description provided.

cid.go Outdated

// WriteTo writes the cids bytes to the given writer
func (c Cid) WriteTo(w io.Writer) error {
_, err := io.WriteString(w, c.str)

Choose a reason for hiding this comment

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

worth checking if this has fully written the string?

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, probably better just to satisfy the WriterTo interface and return the write size

Copy link

@willscott willscott May 1, 2020

Choose a reason for hiding this comment

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

this won't work with the IO methods unless it has a loop as i'm reading the interface contract.
It should either go until there's an error, or until it's written the full string - right?
ref: https://golang.org/pkg/io/#WriterTo

Copy link
Member Author

Choose a reason for hiding this comment

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

mmm, i think youre right there.... Maybe i'll pick a different function name. I don't particularly care for loops here

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Personally I just abuse KeyString, but this is a nicer way to go.

@whyrusleeping whyrusleeping merged commit c1c89c2 into master May 1, 2020
@mvdan mvdan deleted the feat/add-methods-for-using-less-memory branch July 1, 2021 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants