gostaticanalysis/forcetypeassert

Analyzer: fourcetypeassert finds type assertions which did forcely

Go

49

46 commits

updated Feb 13, 2025

See the code

README

forcetypeassert

godoc.org

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
	}
}

Significant stargazers

silverwind

662 followers · starred Aug 2026

Pranshu Srivastava

151 followers · starred Aug 2024

Karim ElDeeb

20 followers · starred Apr 2021

gostaticanalysis/forcetypeassert

Analyzer: fourcetypeassert finds type assertions which did forcely

Go

49

46 commits

updated Feb 13, 2025

See the code

README

forcetypeassert

godoc.org

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
	}
}

Significant stargazers

silverwind

662 followers · starred Aug 2026

Pranshu Srivastava

151 followers · starred Aug 2024

Karim ElDeeb

20 followers · starred Apr 2021

Languages

Go

100.0%