diff --git a/cmd/hdfs/cat.go b/cmd/hdfs/cat.go index 488cb07..3bfa58f 100644 --- a/cmd/hdfs/cat.go +++ b/cmd/hdfs/cat.go @@ -11,7 +11,7 @@ import ( var tailSearchSize int64 = 16384 -func cat(paths []string) int { +func cat(paths []string) { expanded, client, err := getClientAndExpandedPaths(paths) if err != nil { fatal(err) @@ -33,11 +33,9 @@ func cat(paths []string) int { if err != nil { fatal(err) } - - return 0 } -func printSection(paths []string, numLines, numBytes int64, fromEnd bool) int { +func printSection(paths []string, numLines, numBytes int64, fromEnd bool) { if numLines != -1 && numBytes != -1 { fatal("You can't specify both -n and -c.") } else if numLines == -1 && numBytes == -1 { @@ -49,7 +47,6 @@ func printSection(paths []string, numLines, numBytes int64, fromEnd bool) int { fatal(err) } - status := 0 for _, p := range expanded { file, err := client.Open(p) if err != nil || file.Stat().IsDir() { @@ -82,8 +79,6 @@ func printSection(paths []string, numLines, numBytes int64, fromEnd bool) int { io.Copy(os.Stdout, reader) } } - - return status } func headLines(file *hdfs.FileReader, numLines int64) { diff --git a/cmd/hdfs/checksum.go b/cmd/hdfs/checksum.go index 36fedde..eb83271 100644 --- a/cmd/hdfs/checksum.go +++ b/cmd/hdfs/checksum.go @@ -5,7 +5,7 @@ import ( "fmt" ) -func checksum(paths []string) int { +func checksum(paths []string) { expanded, client, err := getClientAndExpandedPaths(paths) if err != nil { fatal(err) @@ -24,6 +24,4 @@ func checksum(paths []string) int { fmt.Println(hex.EncodeToString(checksum), p) } - - return 0 } diff --git a/cmd/hdfs/chmod.go b/cmd/hdfs/chmod.go index 2c76607..1bc2567 100644 --- a/cmd/hdfs/chmod.go +++ b/cmd/hdfs/chmod.go @@ -6,7 +6,7 @@ import ( "strconv" ) -func chmod(args []string, recursive bool) int { +func chmod(args []string, recursive bool) { if len(args) < 2 { printHelp() } @@ -21,7 +21,6 @@ func chmod(args []string, recursive bool) int { fatal(err) } - status := 0 visit := func(p string, fi os.FileInfo) { err := client.Chmod(p, os.FileMode(mode)) @@ -47,6 +46,4 @@ func chmod(args []string, recursive bool) int { visit(p, info) } } - - return status } diff --git a/cmd/hdfs/chown.go b/cmd/hdfs/chown.go index 1167ebc..6afc921 100644 --- a/cmd/hdfs/chown.go +++ b/cmd/hdfs/chown.go @@ -6,7 +6,7 @@ import ( "strings" ) -func chown(args []string, recursive bool) int { +func chown(args []string, recursive bool) { if len(args) < 2 { printHelp() } @@ -30,7 +30,6 @@ func chown(args []string, recursive bool) int { fatal(err) } - status := 0 visit := func(p string, fi os.FileInfo) { err := client.Chown(p, owner, group) @@ -56,6 +55,4 @@ func chown(args []string, recursive bool) int { visit(p, info) } } - - return status } diff --git a/cmd/hdfs/get.go b/cmd/hdfs/get.go index 7e6f773..4846444 100644 --- a/cmd/hdfs/get.go +++ b/cmd/hdfs/get.go @@ -9,7 +9,7 @@ import ( "strings" ) -func get(args []string) int { +func get(args []string) { if len(args) == 0 || len(args) > 2 { printHelp() } @@ -59,11 +59,9 @@ func get(args []string) int { if err != nil { fatal(err) } - - return 0 } -func getmerge(args []string, addNewlines bool) int { +func getmerge(args []string, addNewlines bool) { if len(args) != 2 { printHelp() } @@ -112,6 +110,4 @@ func getmerge(args []string, addNewlines bool) int { if err != nil { fatal(err) } - - return 0 } diff --git a/cmd/hdfs/ls.go b/cmd/hdfs/ls.go index 2d808a0..72825c4 100644 --- a/cmd/hdfs/ls.go +++ b/cmd/hdfs/ls.go @@ -6,13 +6,13 @@ import ( "io" "os" "path" - "strings" "strconv" + "strings" "text/tabwriter" "time" ) -func ls(paths []string, long, all, humanReadable bool) int { +func ls(paths []string, long, all, humanReadable bool) { paths, client, err := getClientAndExpandedPaths(paths) if err != nil { fatal(err) @@ -64,8 +64,6 @@ func ls(paths []string, long, all, humanReadable bool) int { printDir(client, dir, long, all, humanReadable) } } - - return 0 } func printDir(client *hdfs.Client, dir string, long, all, humanReadable bool) { diff --git a/cmd/hdfs/main.go b/cmd/hdfs/main.go index 95fdcb4..c0fd771 100644 --- a/cmd/hdfs/main.go +++ b/cmd/hdfs/main.go @@ -63,6 +63,7 @@ Valid commands: getmergen = getmergeOpts.Bool('n') cachedClient *hdfs.Client + status = 0 ) func init() { @@ -81,41 +82,40 @@ func main() { command := os.Args[1] argv := os.Args[1:] - status := 0 switch command { case "ls": lsOpts.Parse(argv) - status = ls(lsOpts.Args(), *lsl, *lsa, *lsh) + ls(lsOpts.Args(), *lsl, *lsa, *lsh) case "rm": rmOpts.Parse(argv) - status = rm(rmOpts.Args(), *rmr, *rmf) + rm(rmOpts.Args(), *rmr, *rmf) case "mv": mvOpts.Parse(argv) - status = mv(mvOpts.Args(), *mvf, *mvT) + mv(mvOpts.Args(), *mvf, *mvT) case "mkdir": mkdirOpts.Parse(argv) - status = mkdir(mkdirOpts.Args(), *mkdirp) + mkdir(mkdirOpts.Args(), *mkdirp) case "touch": touchOpts.Parse(argv) - status = touch(touchOpts.Args(), *touchc) + touch(touchOpts.Args(), *touchc) case "chown": chownOpts.Parse(argv) - status = chown(chownOpts.Args(), *chownR) + chown(chownOpts.Args(), *chownR) case "chmod": chmodOpts.Parse(argv) - status = chmod(chmodOpts.Args(), *chmodR) + chmod(chmodOpts.Args(), *chmodR) case "cat": - status = cat(argv[1:]) + cat(argv[1:]) case "head", "tail": headTailOpts.Parse(argv) - status = printSection(headTailOpts.Args(), *headtailn, *headtailc, (command == "tail")) + printSection(headTailOpts.Args(), *headtailn, *headtailc, (command == "tail")) case "checksum": - status = checksum(argv[1:]) + checksum(argv[1:]) case "get": - status = get(argv[1:]) + get(argv[1:]) case "getmerge": getmergeOpts.Parse(argv) - status = getmerge(getmergeOpts.Args(), *getmergen) + getmerge(getmergeOpts.Args(), *getmergen) // it's a seeeeecret command case "complete": complete(argv) diff --git a/cmd/hdfs/mkdir.go b/cmd/hdfs/mkdir.go index 1189374..11ce1bf 100644 --- a/cmd/hdfs/mkdir.go +++ b/cmd/hdfs/mkdir.go @@ -4,7 +4,7 @@ import ( "os" ) -func mkdir(paths []string, all bool) int { +func mkdir(paths []string, all bool) { paths, nn, err := normalizePaths(paths) if err != nil { fatal(err) @@ -35,6 +35,4 @@ func mkdir(paths []string, all bool) int { fatal(err) } } - - return 0 } diff --git a/cmd/hdfs/mv.go b/cmd/hdfs/mv.go index 3a88549..6b419e7 100644 --- a/cmd/hdfs/mv.go +++ b/cmd/hdfs/mv.go @@ -6,7 +6,7 @@ import ( "path" ) -func mv(paths []string, force, treatDestAsFile bool) int { +func mv(paths []string, force, treatDestAsFile bool) { paths, nn, err := normalizePaths(paths) if err != nil { fatal(err) @@ -44,8 +44,6 @@ func mv(paths []string, force, treatDestAsFile bool) int { moveTo(client, sources[0], dest, force) } - - return 0 } func moveInto(client *hdfs.Client, sources []string, dest string, force bool) { diff --git a/cmd/hdfs/rm.go b/cmd/hdfs/rm.go index 2b38b39..18a8d6d 100644 --- a/cmd/hdfs/rm.go +++ b/cmd/hdfs/rm.go @@ -6,13 +6,12 @@ import ( "os" ) -func rm(paths []string, recursive bool, force bool) int { +func rm(paths []string, recursive bool, force bool) { expanded, client, err := getClientAndExpandedPaths(paths) if err != nil { fatal(err) } - status := 0 for _, p := range expanded { info, err := client.Stat(p) if err != nil { @@ -40,6 +39,4 @@ func rm(paths []string, recursive bool, force bool) int { fatal(err) } } - - return status } diff --git a/cmd/hdfs/touch.go b/cmd/hdfs/touch.go index bdff583..9dbc6a2 100644 --- a/cmd/hdfs/touch.go +++ b/cmd/hdfs/touch.go @@ -5,7 +5,7 @@ import ( "time" ) -func touch(paths []string, noCreate bool) int { +func touch(paths []string, noCreate bool) { paths, nn, err := normalizePaths(paths) if err != nil { fatal(err) @@ -45,6 +45,4 @@ func touch(paths []string, noCreate bool) int { fatal(err) } } - - return 0 }