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

chore: Enable golangci-lint and fix errors #554

Merged
merged 2 commits into from
Feb 18, 2021
Merged

chore: Enable golangci-lint and fix errors #554

merged 2 commits into from
Feb 18, 2021

Conversation

stevenh
Copy link
Collaborator

@stevenh stevenh commented Feb 7, 2021

Enable golangci-lint checking in travis and fix errors identified by it.

Enable golangci-lint checking in travis and fix errors identified by it.
activeConn.Close now returns any error from operations it performs
instead of always returning nil.
@stevenh stevenh marked this pull request as ready for review February 12, 2021 10:10
@stevenh
Copy link
Collaborator Author

stevenh commented Feb 12, 2021

@darkliquid @danmrichards could I get a review on this please

Comment on lines +63 to +65
if err := c.Conn.Send("SUBSCRIBE", channel...); err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Changes like this seem quite dangerous. While this is the correct behaviour, I do worry about the effect on applications using this package depending on the current behaviour of flush the connection regardless of the outcome of the send. Potentially this warrants a minor or even major version bump depending on how impactful this could be.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My take on this particular case is that the Flush should be returning an error if the Send failed i.e. if Send failed Flush should also. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, digging into it a bit more, conn is using a bufio.Writer for writes, whose behaviour described here https://golang.org/pkg/bufio/#Writer indicates that should a Write call to it fail (which is what Send will ultimately end up doing) then subsequent calls to Flush should also fail, so yeah, I think it's fine as it shouldn't actually result in a change in behaviour anyway.

c.Do("PUBLISH", "c2", "world")
c.Do("PUBLISH", "c1", "goodbye")
if _, err = c.Do("PUBLISH", "c1", "hello"); err != nil {
fmt.Println(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason for using fmt.Println here over say t.Log()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's because this is an example not a test, so trying to be more real.

Copy link

@danmrichards danmrichards left a comment

Choose a reason for hiding this comment

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

LGTM

@stevenh stevenh merged commit dbd3ec6 into master Feb 18, 2021
@stevenh stevenh deleted the golangci-lint branch February 18, 2021 13:19
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.

3 participants