Standard library / flag
flag.NewFlagSet()
Creates an independent parser with a name and explicit error policy. Expected stdout: 'serve\n'.
Formal Syntax & Structure
go syntaxgo
func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSetParameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Name of the flag or flag set. |
| errorHandling | ErrorHandling | Policy for parse errors and help requests. |
Return Value
*FlagSet
Creates an independent parser with a name and explicit error policy.
Working Example
Example Snippetgo
package main
import ( "flag" "fmt")
func main() { f := flag.NewFlagSet("serve", flag.ContinueOnError); fmt.Println(f.Name()) }