Rev 27 | Rev 37 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 27 | Rev 28 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | //usr/bin/env go run $0 $@; exit $? |
|
1 | package main |
2 | package main |
2 | 3 | ||
3 | import ( |
4 | import ( |
4 | "fmt" |
5 | "fmt" |
5 | "io/ioutil" |
6 | "io/ioutil" |
6 | "log" |
7 | "log" |
7 | "os" |
8 | "os" |
8 | ) |
9 | ) |
9 | 10 | ||
- | 11 | // ============================================================================= |
|
- | 12 | // Functions |
|
- | 13 | // ============================================================================= |
|
- | 14 | ||
10 | func traverse(s string) { |
15 | func traverse(s string) { |
11 | curdir, err := os.Getwd() |
16 | curdir, err := os.Getwd() |
12 | if err := os.Chdir(s); err != nil { |
17 | if err := os.Chdir(s); err != nil { |
13 | log.Fatal(err) |
18 | log.Fatal(err) |
14 | } |
19 | } |
Line 38... | Line 43... | ||
38 | func start_traverse(s string) { |
43 | func start_traverse(s string) { |
39 | fmt.Println(s) |
44 | fmt.Println(s) |
40 | traverse(s) |
45 | traverse(s) |
41 | } |
46 | } |
42 | 47 | ||
- | 48 | // ============================================================================= |
|
- | 49 | // MAIN |
|
- | 50 | // ============================================================================= |
|
- | 51 | ||
43 | func main() { |
52 | func main() { |
- | 53 | if len(os.Args) < 2 { |
|
- | 54 | log.Fatal("Give a directory as argument") |
|
- | 55 | } |
|
44 | arg := os.Args[1] |
56 | arg := os.Args[1] |
45 | fi, err := os.Stat(arg) |
57 | fi, err := os.Stat(arg) |
46 | if err != nil { |
58 | if err != nil { |
47 | log.Fatal(err) |
59 | log.Fatal(err) |
48 | } |
60 | } |