Standard library / flag
flag.Args()
Returns remaining arguments after parsing stops at the first positional argument or --. Run with arguments: ["file", "-x"]. Expected stdout: '[file -x]\n'.
Formal Syntax & Structure
go syntaxgo
func Args() []stringReturn Value
[]string
Returns remaining arguments after parsing stops at the first positional argument or --.
Working Example
Example Snippetgo
package main
import ( "flag" "fmt")
func main() { v := flag.Int("x", 0, "value"); _ = v; flag.Parse(); fmt.Println(flag.Args()) }