fmt.Print()是否在GoLang中写入stdout?

biw*_*biw 22 go

我可能过分夸大了这一点,但在GoLang中,是fmt.Print()写到stdout还是我必须使用os.Stdout.Write

rig*_*old 22

文档:

使用其操作数的默认格式打印格式并写入标准输出.

所以,它写给stdout.


Sim*_*tti 11

是的,它确实.从源代码:

// Print formats using the default formats for its operands and writes to standard output.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
func Print(a ...interface{}) (n int, err error) {
    return Fprint(os.Stdout, a...)
}
Run Code Online (Sandbox Code Playgroud)

os.Stdout 确实代表标准输出流.