aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorKaushal Subedi2015-10-26 21:00:44 -0600
committerKaushal Subedi2015-10-26 21:00:44 -0600
commitc3aad4d448840ddefcb15fb689ecb69444a9a9f7 (patch)
tree51b03088eddbaae63b392d7fd5c0b6fcd44f5fe2 /main.go
parentc78a0df497330138e7938d183a6aff42f18a6466 (diff)
downloadgomove-c3aad4d448840ddefcb15fb689ecb69444a9a9f7.tar.bz2
minor refactoring and added comments
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.go b/main.go
index e7c51df..3d5d856 100644
--- a/main.go
+++ b/main.go
@@ -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
})