@@ -2,8 +2,6 @@ package golinters
22
33import (
44 "fmt"
5- "path/filepath"
6- "regexp"
75 "strings"
86 "sync"
97
@@ -12,6 +10,7 @@ import (
1210 "golang.org/x/tools/go/loader" //nolint:staticcheck // require changes in github.com/OpenPeeDeeP/depguard
1311
1412 "github.com/golangci/golangci-lint/pkg/config"
13+ "github.com/golangci/golangci-lint/pkg/fsutils"
1514 "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
1615 "github.com/golangci/golangci-lint/pkg/lint/linter"
1716 "github.com/golangci/golangci-lint/pkg/result"
@@ -106,16 +105,6 @@ func (d depGuard) run(pass *analysis.Pass) ([]goanalysis.Issue, error) {
106105 return resIssues , nil
107106}
108107
109- var separatorToReplace = regexp .QuoteMeta (string (filepath .Separator ))
110-
111- // normalizePathInRegex normalizes path in regular expressions.
112- // noop on Unix.
113- // This replacing should be safe because "/" are disallowed in Windows
114- // https://docs.microsoft.com/windows/win32/fileio/naming-a-file
115- func normalizePathInRegex (path string ) string {
116- return strings .ReplaceAll (path , "/" , separatorToReplace )
117- }
118-
119108type guardian struct {
120109 * depguard.Depguard
121110 pkgsWithErrorMessage map [string ]string
@@ -124,7 +113,7 @@ type guardian struct {
124113func newGuardian (settings * config.DepGuardSettings ) (* guardian , error ) {
125114 var ignoreFileRules []string
126115 for _ , rule := range settings .IgnoreFileRules {
127- ignoreFileRules = append (ignoreFileRules , normalizePathInRegex (rule ))
116+ ignoreFileRules = append (ignoreFileRules , fsutils . NormalizePathInRegex (rule ))
128117 }
129118
130119 dg := & depguard.Depguard {
0 commit comments