Skip to content

Hope to add detection of overflow during integer conversion #4678

@findmyhappy

Description

@findmyhappy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions