mirror of
https://github.com/golang/go
synced 2024-11-18 22:14:56 -07:00
e1f38ccab1
CommandLine (exported in Go 1.2) has default output of os.Stderr. Before it was exported, it made sense to have the global Usage func (the implicit usage func if CommandLine.Usage is nil) hard-code os.Stderr has its output. But once CommandLine was exported, Usage should use it if provided. Fixes #20998 Change-Id: I9e1c0415a563a982634b9808199c9ee175d72f4c Reviewed-on: https://go-review.googlesource.com/48390 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
21 lines
607 B
Go
21 lines
607 B
Go
// Copyright 2010 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package flag
|
|
|
|
import "os"
|
|
|
|
// Additional routines compiled into the package only during testing.
|
|
|
|
var DefaultUsage = Usage
|
|
|
|
// ResetForTesting clears all flag state and sets the usage function as directed.
|
|
// After calling ResetForTesting, parse errors in flag handling will not
|
|
// exit the program.
|
|
func ResetForTesting(usage func()) {
|
|
CommandLine = NewFlagSet(os.Args[0], ContinueOnError)
|
|
CommandLine.Usage = commandLineUsage
|
|
Usage = usage
|
|
}
|