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

Hope to add detection of overflow during integer conversion #4678

Open
findmyhappy opened this issue Apr 25, 2024 · 1 comment
Open

Hope to add detection of overflow during integer conversion #4678

findmyhappy opened this issue Apr 25, 2024 · 1 comment
Labels
linter: idea idea of a linter

Comments

@findmyhappy
Copy link

findmyhappy commented Apr 25, 2024

Your feature request related to a problem? Please describe

There seems to be no good way to detect if there is a risk of overflow when converting between integers, e.g. from uint32 to int32.

Describe the solution you'd like

I hope to add a lint that can detect this situation

Describe alternatives you've considered

No

Additional context

package main

import "fmt"

func main() {
	num := 300
	u8 := uint8(num)
	fmt.Println(u8)
}

I hope there is a tool that can give me a hint

@findmyhappy findmyhappy added the enhancement New feature or improvement label Apr 25, 2024
@ldez ldez added linter: idea idea of a linter and removed enhancement New feature or improvement labels Apr 25, 2024
@Antonboom
Copy link
Contributor

Looks like candidate for "go vet" or "gocritic".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linter: idea idea of a linter
Projects
None yet
Development

No branches or pull requests

3 participants