From 866f17b86f3dd75820dfcf69ed9ed2290f538186 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Tue, 21 Sep 2021 00:02:01 +0200 Subject: [PATCH] getModuleDeps: replace Split() loop with ReplaceAllString() (MR 12) This should do the same as far as I can tell :) --- main.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/main.go b/main.go index 4302ad1..8c4de9f 100644 --- a/main.go +++ b/main.go @@ -657,14 +657,7 @@ func getModuleDeps(modName string, modulesDep io.Reader) ([]string, error) { // split the module name on - and/or _, build a regex for matching splitRe := regexp.MustCompile("[-_]+") - var modNameReStr string - for _, s := range splitRe.Split(modName, -1) { - if modNameReStr != "" { - modNameReStr += "[-_]+" + s - } else { - modNameReStr = s - } - } + modNameReStr := splitRe.ReplaceAllString(modName, "[-_]+") re := regexp.MustCompile("^" + modNameReStr + "$") s := bufio.NewScanner(modulesDep)