Skip to content

Analyzer: fourcetypeassert finds type assertions which did forcely

License

Notifications You must be signed in to change notification settings

gostaticanalysis/forcetypeassert

Repository files navigation

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

About

Analyzer: fourcetypeassert finds type assertions which did forcely

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages