tags:

views:

129

answers:

3

I can't see arguments for main() in package main.
How to pass arguments from command line in Go?

A complete program, possibly created by linking multiple packages, 
must have one package called main, with a function

func main() { ... }

defined. The function main.main() takes no arguments and returns no value. 
+3  A: 

You should take a look at the flag package

RC
@RC: thanks, missed this
oraz
+2  A: 

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.

Maurice Gilden
+7  A: 

You can access the command-line arguments using the os.Args variable. For example,

package main

import ("fmt"; "os")

func main() {
    fmt.Println(len(os.Args), os.Args)
}

You can also use the flag package, which implements command-line flag parsing. For an example of its use, see the Echo program in the Tutorial for the Go Programming Language.

peterSO