Command Line Argument Processing in Go: Difference between revisions
Jump to navigation
Jump to search
Line 11: | Line 11: | ||
flag.Parse() | flag.Parse() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Positional Arguments= | |||
<syntaxhighlight lang='go'> | |||
args := os.Args | |||
</syntaxhighlight> | |||
<code>args[0]</code> is the executable. |
Revision as of 22:08, 5 October 2023
Internal
Overview
Use the flag
package:
var port int
flag.IntVar(&port, "port", 8080, "Some documentation for the flag")
flag.Parse()
Positional Arguments
args := os.Args
args[0]
is the executable.