aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushal Subedi2018-12-13 18:59:02 -0700
committerGitHub2018-12-13 18:59:02 -0700
commit9efbee930b0e1fb46fb56eca5512620b22db126b (patch)
tree8811a77f214b0c10eaecd2b28a4748f6ae42876e
parentaccb140e81998d3630825d7e236f603e43d5cf07 (diff)
parent33304658dfdfa29d25c00b274b97d01e0bfc4a88 (diff)
downloadgomove-9efbee930b0e1fb46fb56eca5512620b22db126b.tar.bz2
Merge pull request #2 from femaref/master
Ignore files under vendor/ dir
-rw-r--r--main.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/main.go b/main.go
index 52fe963..1baef3c 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"os"
"path"
"path/filepath"
+ "strings"
"github.com/codegangsta/cli"
)
@@ -20,7 +21,7 @@ func main() {
cli.StringFlag{
Name: "dir, d",
Value: "./",
- Usage: "directory to scan",
+ Usage: "directory to scan. files under vendor/ are ignored",
},
cli.StringFlag{
Name: "file, f",
@@ -52,15 +53,21 @@ func main() {
// 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 != "" {
+ // construct the path of the vendor dir of the project for prefix matching
+ vendorDir := path.Join(dir, "vendor")
// Scan directory for files
filepath.Walk(dir, func(filePath string, info os.FileInfo, err error) error {
+ // ignore vendor path
+ if matched := strings.HasPrefix(filePath, vendorDir); matched {
+ return nil
+ }
// Only process go files
if path.Ext(filePath) == ".go" {
ProcessFile(filePath, from, to, c)
}
+
return nil
})