Analyzer: fourcetypeassert finds type assertions which did forcely
Go
49
46 commits
updated Feb 13, 2025
forcetypeassert finds type assertions which did forcely such as below.
func f() {
var a interface{}
_ = a.(int) // type assertion must be checked
}
You need to check if the assertion failed like so:
func f() {
var a interface{}
_, ok := a.(int)
if !ok { // type assertion failed
// handle error
}
}
662 followers · starred Aug 2026
151 followers · starred Aug 2024
20 followers · starred Apr 2021
Go
100.0%
Analyzer: fourcetypeassert finds type assertions which did forcely
Go
49
46 commits
updated Feb 13, 2025
forcetypeassert finds type assertions which did forcely such as below.
func f() {
var a interface{}
_ = a.(int) // type assertion must be checked
}
You need to check if the assertion failed like so:
func f() {
var a interface{}
_, ok := a.(int)
if !ok { // type assertion failed
// handle error
}
}
662 followers · starred Aug 2026
151 followers · starred Aug 2024
20 followers · starred Apr 2021
Go
100.0%