From 416fb2ec9d72dee8a8492971595a9911da48d953 Mon Sep 17 00:00:00 2001 From: Vladimir Alaev Date: Wed, 12 Jul 2017 17:23:53 +0300 Subject: [PATCH] Fix: docs generator skips everything containing 'vendor' in path which is wrong. Fixed that to skip only the 'vendor' dir directly under the project root. Also don't even scan a dir beginning with a '.'. --- generate/swaggergen/g_docs.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index ae8f297..92c7ed8 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -104,7 +104,11 @@ func ParsePackagesFromDir(dirpath string) { return nil } - if !strings.Contains(fpath, "vendor") && !strings.Contains(fpath, "tests") { + // 7 is length of 'vendor' (6) + length of file path separator (1) + // so we skip dir 'vendor' which is directly under dirpath + if !(len(fpath) == len(dirpath)+7 && strings.HasSuffix(fpath, "vendor")) && + !strings.Contains(fpath, "tests") && + !(len(fpath) > len(dirpath) && fpath[len(dirpath)+1] == '.') { err = parsePackageFromDir(fpath) if err != nil { // Send the error to through the channel and continue walking