Command Line Argument Processing in Go
Jump to navigation
Jump to search
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 a string that represents the path of the executable, as it was invoked on the command line. Example: ./../bin/metadata
.