Standard library / flag

flag.Usage

Replaceable default command-line help callback. Set it to describe usage without exposing secrets. Expected stdout: 'demo help\n'.

Formal Syntax & Structure

go syntaxgo
var Usage func()

Working Example

Example Snippetgo
package main
import (  "flag"  "fmt"  "os")
func main() {  flag.Usage = func() { fmt.Fprintln(flag.CommandLine.Output(), "demo help") }  flag.CommandLine.SetOutput(os.Stdout)  flag.Usage()}
Go Reference