Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created April 9, 2018 08:12
Show Gist options
  • Save hyuki/f0359047148408923a984c36b47fb77f to your computer and use it in GitHub Desktop.
Save hyuki/f0359047148408923a984c36b47fb77f to your computer and use it in GitHub Desktop.
os.Args
package main
import (
"fmt"
"os"
)
func main() {
for index,cmd := range os.Args {
fmt.Printf("os.Args[%d] = %s\n", index,cmd)
}
}
@hyuki
Copy link
Author

hyuki commented Apr 9, 2018

$ go run a.go 123 456 789
os.Args[0] = /var/folders/jp/sx9b56f53436_nygd621vx_80000gn/T/go-build173715180/command-line-arguments/_obj/exe/a
os.Args[1] = 123
os.Args[2] = 456
os.Args[3] = 789

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment