Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created Apr 9, 2018
Embed
What would you like to do?
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