getModuleDeps: replace Split() loop with ReplaceAllString() (MR 12)

This should do the same as far as I can tell :)
This commit is contained in:
Minecrell
2021-09-21 00:02:01 +02:00
committed by Clayton Craft
parent 15e99c3658
commit 866f17b86f

View File

@@ -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)