Command Line Argument Processing in Go

From NovaOrdis Knowledge Base
Revision as of 22:08, 5 October 2023 by Ovidiu (talk | contribs) (→‎Overview)
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 the executable.