package main import ( "fmt" "os" "path" ) func usage() { fmt.Printf("usage: %v path\n", os.Args[0]) } func main() { if len(os.Args) != 2 { usage() os.Exit(1) } fmt.Println(path.Dir(os.Args[1])) }