gordonklaus/ineffassign

Unexpected ineffectual assignment after switch

Closed this issue · 1 comments

Hello!

package main

import "fmt"

func returnFalse() bool {
	return false
}

func returnTrue() bool {
	return true
}

func main() {
	isValid := true

	var i interface{} = 100

	switch i.(type) {
	case int:
		isValid = returnFalse()
	default:
		isValid = returnTrue()
	}
	if !isValid {
		fmt.Println("value changed")
	}
}
▶ ineffassign main.go 
/Users/anthony/main.go:14:2: ineffectual assignment to isValid

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

Thank u for linter!