Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Update MustCompile usage with dynamic content
Browse files Browse the repository at this point in the history
Signed-off-by: thepetk <thepetk@gmail.com>
  • Loading branch information
thepetk committed May 4, 2023
1 parent e48ae9e commit 2d94fa5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions go/pkg/utils/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ func GetPortValuesFromEnvFile(root string, regexes []string) []int {
return ports
}
for _, regex := range regexes {
re := regexp.MustCompile(regex)
re, err := regexp.Compile(regex)
if err != nil {
continue
}
port := FindPortSubmatch(re, text, 1)
if port != -1 {
ports = append(ports, port)
Expand All @@ -420,7 +423,10 @@ func GetStringValueFromEnvFile(root string, regex string) string {
if err != nil {
return ""
}
re := regexp.MustCompile(regex)
re, err := regexp.Compile(regex)
if err != nil {
return ""
}
if text != "" {
matches := re.FindStringSubmatch(text)
if len(matches) > 1 {
Expand Down

0 comments on commit 2d94fa5

Please sign in to comment.