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")

}
上一篇:python-如何从使用鼻子测试输出中删除调试


下一篇:在Linux系统上,如何将stdout重定向到stderr?