package main import ( "errors" "fmt2" ) func main() { err := errors.New("emit macho dwarf: elf header corrupted") if err != nil { fmt2.Println(err.Error(), 1, 2, 3, "tata") } var errNil error assert(errNil == nil) var sliceNil []int assert(sliceNil == nil) slice := make([]int, 1) assert(slice != nil) var mapNil map[int]string assert(mapNil == nil) mapNil[1] = "aa" m := make(map[int]string) assert(m != nil) m[1] = "aa" _, ok := err.(*errorString) assert(!ok) err2 := New("haha") _, ok2 := err2.(*errorString) assert(ok2) fmt2.Println(ok, ok2, m[1]) } func New(text string) error { return &errorString{text} } // errorString is a trivial implementation of error. type errorString struct { s string } func (e *errorString) Error() string { return e.s }