github.com/dorkamotorka/go/src@v0.0.0-20230614113921-187095f0e316/flag/export_test.go (about)

     1  // Copyright 2010 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package flag
     6  
     7  import (
     8  	"io"
     9  	"os"
    10  )
    11  
    12  // Additional routines compiled into the package only during testing.
    13  
    14  var DefaultUsage = Usage
    15  
    16  // ResetForTesting clears all flag state and sets the usage function as directed.
    17  // After calling ResetForTesting, parse errors in flag handling will not
    18  // exit the program.
    19  func ResetForTesting(usage func()) {
    20  	CommandLine = NewFlagSet(os.Args[0], ContinueOnError)
    21  	CommandLine.SetOutput(io.Discard)
    22  	CommandLine.Usage = commandLineUsage
    23  	Usage = usage
    24  }