fmt.Print() 是否写入 Go 语言中的标准输出?

Does fmt.Print() write to stdout in GoLang?

我可能想太多了,但是在 GoLang 中,fmt.Print() 是写入标准输出还是我必须使用 os.Stdout.Write

来自the documentation

Print formats using the default formats for its operands and writes to standard output.

是的,它写入标准输出。

来自 Print documentation使用其操作数的默认格式打印格式并写入标准输出。

是的,确实如此。 From the source code:

// 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...)
}

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