mirror of
https://github.com/golang/go
synced 2024-11-19 10:14:44 -07:00
cmd/compile: print usage to stderr for consistency
All the other tools and commands print the usage text to standard error. "go tool compile" was the odd one out, so fix it. While at it, make objabi.Flagprint a bit more Go-like with an io.Writer instead of a file descriptor, which is likely a leftover from the C days. Fixes #23234. Change-Id: I9abf2e79461e61c8c8bfaee2c6bf8faf26e0e6c3 Reviewed-on: https://go-review.googlesource.com/85418 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
ddb503be96
commit
7ddd467ef3
@ -94,8 +94,8 @@ Key "pctab" supports values:
|
||||
`
|
||||
|
||||
func usage() {
|
||||
fmt.Printf("usage: compile [options] file.go...\n")
|
||||
objabi.Flagprint(1)
|
||||
fmt.Fprintf(os.Stderr, "usage: compile [options] file.go...\n")
|
||||
objabi.Flagprint(os.Stderr)
|
||||
Exit(2)
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ package objabi
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -20,10 +21,8 @@ func Flagfn1(name, usage string, f func(string)) {
|
||||
flag.Var(fn1(f), name, usage)
|
||||
}
|
||||
|
||||
func Flagprint(fd int) {
|
||||
if fd == 1 {
|
||||
flag.CommandLine.SetOutput(os.Stdout)
|
||||
}
|
||||
func Flagprint(w io.Writer) {
|
||||
flag.CommandLine.SetOutput(w)
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
|
@ -1953,7 +1953,7 @@ func stkprint(ctxt *Link, ch *chain, limit int) {
|
||||
|
||||
func usage() {
|
||||
fmt.Fprintf(os.Stderr, "usage: link [options] main.o\n")
|
||||
objabi.Flagprint(2)
|
||||
objabi.Flagprint(os.Stderr)
|
||||
Exit(2)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user