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

octalLiteral warns when binary literal is used #1149

Closed
beantowel opened this issue Nov 2, 2021 · 5 comments · Fixed by #1150
Closed

octalLiteral warns when binary literal is used #1149

beantowel opened this issue Nov 2, 2021 · 5 comments · Fixed by #1150
Assignees
Labels
bug Something isn't working

Comments

@beantowel
Copy link

const (
	bit1   = uint8(0b_00000001)
	minus1 = uint8(0b_11111111)
	nBit   = 3
)

This binary literal looks clear enough to distinguish from normal digits, but we got "octalLiteral" warning. go-critic should fix this warning for binary literals.

@cristaloleg cristaloleg added the bug Something isn't working label Nov 2, 2021
@cristaloleg cristaloleg self-assigned this Nov 2, 2021
@cristaloleg
Copy link
Member

Thanks for reporting, will try to fix today 😉

@cristaloleg
Copy link
Member

Have tried in the latest go-critic and do not see a problem, can you share what version do you use? how does the error looks like? thanks.

@quasilyte
Copy link
Member

We need to add some base-2 literals to our negative tests suite for octalLiteral anyway.

@beantowel
Copy link
Author

I am using github.com/go-critic/go-critic v0.5.6, the error looks like:

mirror/cron.go:18:11: octalLiteral: suspicious octal args in `uint8(0b_00000001)` (gocritic)
	bit1   = uint8(0b_00000001)

@quasilyte
Copy link
Member

It looks like it's a warning from the old go-critic version.
We're giving a different warning now for octalLiteral.

quasilyte added a commit that referenced this issue Nov 3, 2021
Cover binary literals.

Also updated a version of golang tools to avoid issues
with newer Go versions.

Fixes #1149
quasilyte added a commit that referenced this issue Nov 3, 2021
Cover binary literals.

Also updated a version of golang tools to avoid issues
with newer Go versions.

Fixes #1149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants