【发布时间】:2022-10-24 20:45:23
【问题描述】:
package main
import (
"bufio"
"os"
)
func main() {
bw := bufio.NewWriter(os.Stdin)
bw2 := bufio.NewWriter(os.Stdout)
bw.WriteString("Hello, world 1\n")
bw2.WriteString("Hello, world 2\n")
bw.Flush()
bw2.Flush()
}
此代码在本地环境中显示这两个字符串。 但是为什么它在不同的环境中工作方式不同呢?
我的本地环境 操作系统:macOS 12.6 去:去1.19.2达尔文/amd64 ide:vscode
- 在我的本地机器上:
$ go run myworkspace/main/main.go
Hello, world 1
Hello, world 2
- 在操场上:
# in the 'Output' section
---
Hello, world 2
Program exited.
【问题讨论】:
-
嗨,关于 StackOverflow 指南的一般评论:粘贴文本在你的问题中,而不是屏幕截图(输出可以完美复制粘贴)
标签: go