1 package mocks 2 3 import ( 4 "reflect" 5 ) 6 7 // AssertNotNil forces a panic if the specified value is nil (either a nil interface value, or a 8 // nil pointer). 9 func AssertNotNil(i interface{}) { 10 if i != nil { 11 val := reflect.ValueOf(i) 12 if val.Kind() != reflect.Ptr || !val.IsNil() { 13 return 14 } 15 } 16 panic("unexpected nil pointer or nil interface value") 17 } 18