Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 584 Bytes

README.md

File metadata and controls

28 lines (22 loc) · 584 Bytes

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