From 0dcd199f6e2c9e5fb738b78bfa2170de4c78a25f Mon Sep 17 00:00:00 2001 From: Kanitkorn S Date: Tue, 23 Jan 2018 15:51:37 +0700 Subject: [PATCH] Fix command panic with a short arg More info: https://github.com/golang/lint/pull/325#discussion_r163038294 --- golint/golint.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/golint/golint.go b/golint/golint.go index c54dd942..00882749 100644 --- a/golint/golint.go +++ b/golint/golint.go @@ -47,12 +47,11 @@ func main() { // checks are run. It is no valid to mix target types. var dirsRun, filesRun, pkgsRun int var args []string - for _, arg := range flag.Args() { - basePath := arg[:len(arg)-len("/...")] - if strings.HasSuffix(arg, "/...") && isDir(basePath) { + for _, arg := range flag.Args() { + if trimmedArg := strings.TrimSuffix(arg, "/..."); trimmedArg != arg && isDir(trimmedArg) { dirsRun = 1 for _, dirname := range allPackagesInFS(arg) { - if strings.Contains(dirname[len(basePath):], "/vendor/") { + if strings.Contains(dirname[len(trimmedArg):], "/vendor/") { continue } args = append(args, dirname)