How to access command-line arguments passed to a Go program?

前端 未结 6 1228
夕颜
夕颜 2020-12-08 01:26

How do I access command-line arguments in Go? They\'re not passed as arguments to main.

A complete program, possibly created by linking m

6条回答
  •  一整个雨季
    2020-12-08 02:06

    Command line arguments can be found in os.Args. In most cases though the package flag is better because it does the argument parsing for you.

提交回复
热议问题