Skip to content

Commit

Permalink
move regexp.MustCompile close to call (#3280)
Browse files Browse the repository at this point in the history
* move regexp.MustCompile out of func

* move moduleRe close to call

---------

Co-authored-by: Nedyalko Dyakov <[email protected]>
  • Loading branch information
alingse and ndyakov authored Feb 20, 2025
1 parent 7e517ec commit f3c2711
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5492,8 +5492,6 @@ func (cmd *InfoCmd) readReply(rd *proto.Reader) error {

section := ""
scanner := bufio.NewScanner(strings.NewReader(val))
moduleRe := regexp.MustCompile(`module:name=(.+?),(.+)$`)

for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "#") {
Expand All @@ -5504,6 +5502,7 @@ func (cmd *InfoCmd) readReply(rd *proto.Reader) error {
cmd.val[section] = make(map[string]string)
} else if line != "" {
if section == "Modules" {
moduleRe := regexp.MustCompile(`module:name=(.+?),(.+)$`)
kv := moduleRe.FindStringSubmatch(line)
if len(kv) == 3 {
cmd.val[section][kv[1]] = kv[2]
Expand Down

0 comments on commit f3c2711

Please sign in to comment.