From dd2f218226ee189bd086b420eae9344293569ac8 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Fri, 25 Aug 2023 16:49:31 +0200 Subject: [PATCH] Use MustCompile for static regexp Signed-off-by: Evan Lezar --- internal/config/toml.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/config/toml.go b/internal/config/toml.go index 8c931675..6561ab1c 100644 --- a/internal/config/toml.go +++ b/internal/config/toml.go @@ -154,10 +154,7 @@ func (t Toml) contents() ([]byte, error) { // format fixes the comments for the config to ensure that they start in column // 1 and are not followed by a space. func (t Toml) format(contents []byte) ([]byte, error) { - r, err := regexp.Compile(`(\n*)\s*?#\s*(\S.*)`) - if err != nil { - return nil, fmt.Errorf("unable to compile regexp: %v", err) - } + r := regexp.MustCompile(`(\n*)\s*?#\s*(\S.*)`) replaced := r.ReplaceAll(contents, []byte("$1#$2")) return replaced, nil