diff options
| author | Kaushal Subedi | 2015-10-26 21:00:44 -0600 |
|---|---|---|
| committer | Kaushal Subedi | 2015-10-26 21:00:44 -0600 |
| commit | c3aad4d448840ddefcb15fb689ecb69444a9a9f7 (patch) | |
| tree | 51b03088eddbaae63b392d7fd5c0b6fcd44f5fe2 /main.go | |
| parent | c78a0df497330138e7938d183a6aff42f18a6466 (diff) | |
| download | gomove-c3aad4d448840ddefcb15fb689ecb69444a9a9f7.tar.bz2 | |
minor refactoring and added comments
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -2,6 +2,7 @@ package main import ( "os" + "path" "path/filepath" "github.com/codegangsta/cli" @@ -36,7 +37,7 @@ func main() { if file != "" { ProcessFileNative(file, from, to) } else { - RunApp(dir, from, to, c) + ScanDir(dir, from, to, c) } } @@ -44,11 +45,17 @@ func main() { app.Run(os.Args) } -func RunApp(dir string, from string, to string, c *cli.Context) { +// ScanDir scans a directory for go files and +func ScanDir(dir string, from string, to string, c *cli.Context) { + // If from and to are not empty scan all files if from != "" && to != "" { + // Scan directory for files filepath.Walk(dir, func(filePath string, info os.FileInfo, err error) error { - ProcessFileNative(filePath, from, to) + // Only process go files + if path.Ext(filePath) == ".go" { + ProcessFileNative(filePath, from, to) + } return nil }) |
