go defer bug

package main

import (
"fmt"
"os"
)

func F() (int, string) {
return 1, "o"
}

func ff(a int, s string) {
fmt.Println(a)
fmt.Println(s)
}

func f(p []byte) {
p[1] = 2
}

func main() {
//ff(F())

var p []byte
if len(os.Args) == 3{
p = make([]byte, 2)
defer f(p)
defer fmt.Fprint(os.Stderr, "1\n")
fmt.Fprint(os.Stderr, "2\n")
}
fmt.Fprint(os.Stderr, "3\n")

}
posted @ 2021-01-14 20:59  zJanly  阅读(83)  评论(0编辑  收藏  举报