gordonklaus / ineffassign

Detect ineffectual assignments in Go code.
MIT License
390 stars 22 forks source link

Unexpected ineffectual assignment: type switch #64

Closed Antonboom closed 2 years ago

Antonboom commented 2 years ago

Hello!

package main

import "fmt"

func main() {
    var i interface{} = 100
    i = "100"

    switch i.(type) {
    case int:
        fmt.Println("int")
    default:
        fmt.Println("not int")
    }
}
$ ineffassign main.go
/Users/anthony/main.go:6:6: ineffectual assignment to i
Antonboom commented 2 years ago

I'm sorry. I didn’t notice which line the linter was pointing to.

Thank u for linter!