From f5f69bba3b0d2563d56eff0935f32d7b252c7df6 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 6 Jan 2015 09:15:13 -0800 Subject: [PATCH] cmd/go: buffer output for go usage It did tons of write syscalls before: https://www.youtube.com/watch?v=t60fhjAqBdw This is the worst offender. It's not worth fixing all the cases of two consecutive prints. Change-Id: I95860ef6a844d89b149528195182b191aad8731b Reviewed-on: https://go-review.googlesource.com/2371 Reviewed-by: Rob Pike --- src/cmd/go/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go index 9691f39c763..9bf227925bf 100644 --- a/src/cmd/go/main.go +++ b/src/cmd/go/main.go @@ -5,6 +5,7 @@ package main import ( + "bufio" "bytes" "flag" "fmt" @@ -236,7 +237,9 @@ func capitalize(s string) string { } func printUsage(w io.Writer) { - tmpl(w, usageTemplate, commands) + bw := bufio.NewWriter(w) + tmpl(bw, usageTemplate, commands) + bw.Flush() } func usage() {