From c3aad4d448840ddefcb15fb689ecb69444a9a9f7 Mon Sep 17 00:00:00 2001 From: Kaushal Subedi Date: Mon, 26 Oct 2015 21:00:44 -0600 Subject: minor refactoring and added comments --- main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'main.go') 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 }) -- cgit v1.2.3