From 5a08a1bc471119eab4acb4220eeda7e2b0004deb Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Fri, 25 Nov 2022 01:21:57 +0700 Subject: [PATCH] refactor: remove regex code generated --- internal/imports/check.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/imports/check.go b/internal/imports/check.go index 8b71762..e8703a8 100644 --- a/internal/imports/check.go +++ b/internal/imports/check.go @@ -2,12 +2,9 @@ package imports import ( "go/ast" - "regexp" "strings" ) -var reGoGenerated = regexp.MustCompile(`^// Code generated .* DO NOT EDIT\.$`) - // Copy from https://github.com/mvdan/gofumpt func isGoFile(name string) bool { // Hidden files are ignored @@ -19,6 +16,7 @@ func isGoFile(name string) bool { } // Copy from https://github.com/mvdan/gofumpt +// Copy from https://github.com/incu6us/goimports-reviser func isGoGenerated(file *ast.File) bool { for _, cg := range file.Comments { // Ignore if package ... is on top @@ -27,7 +25,7 @@ func isGoGenerated(file *ast.File) bool { } for _, line := range cg.List { - if reGoGenerated.MatchString(line.Text) { + if strings.Contains(line.Text, "// Code generated") { return true } }