Standard library / flag

flag.Parse()

Parses registered flags; uses os.Args[1:] and default command-line exit handling. Run with arguments: ["-x=5"]. Expected stdout: '5\n'.

Formal Syntax & Structure

go syntaxgo
func Parse()

Working Example

Example Snippetgo
package main
import (  "flag"  "fmt")
func main() { v := flag.Int("x", 0, "value"); flag.Parse(); fmt.Println(*v) }
Go Reference