Standard library / flag

flag.ErrHelp

Sentinel returned for an undefined -h or -help flag under ContinueOnError. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
var ErrHelp error

Working Example

Example Snippetgo
package main
import (  "errors"  "flag"  "fmt"  "io")
func main() {  f := flag.NewFlagSet("demo", flag.ContinueOnError)  f.SetOutput(io.Discard)  fmt.Println(errors.Is(f.Parse([]string{"-h"}), flag.ErrHelp))}
Go Reference