funcfoo() { var cn chanint var sl []int var m = make(map[string]int, 10) m["a"] = 1 m["b"] = 2 var c = complex(1.0, -1.4)
var sl1 []int
defer bar()
deferclose(cn) defercopy(sl1, sl) deferdelete(m, "a") deferprint(1) deferprintln(1) deferpanic(1) // ok, but defer should not call panic() directly deferrecover() // ok, but defer should not call recover() directly
deferappend(sl, 11) // defer discards result of append(sl, 11) defercap(sl) // defer discards result of cap(sl) defercomplex(2, -2) // defer discards result of complex(2, -2) deferimag(c) // defer discards result of imag(c) deferlen(sl) // defer discards result of len(sl) defermake([]int, 10) // defer discards result of make([]int, 10) defernew(*int) // defer discards result of new(*int) deferreal(c) // defer discards result of real(c) }
funcfoo() { var cn chanint var sl []int var m = make(map[string]int, 10) m["a"] = 1 m["b"] = 2 var c = complex(1.0, -1.4)
var sl1 []int
defer bar()
deferclose(cn) defercopy(sl1, sl) deferdelete(m, "a") deferprint(1) deferprintln(1) deferpanic(1) // ok, but defer should not call panic() directly deferrecover() // ok, but defer should not call recover() directly