@@ -2,8 +2,6 @@ package golinters
2
2
3
3
import (
4
4
"fmt"
5
- "path/filepath"
6
- "regexp"
7
5
"strings"
8
6
"sync"
9
7
@@ -12,6 +10,7 @@ import (
12
10
"golang.org/x/tools/go/loader" //nolint:staticcheck // require changes in github.com/OpenPeeDeeP/depguard
13
11
14
12
"github.com/golangci/golangci-lint/pkg/config"
13
+ "github.com/golangci/golangci-lint/pkg/fsutils"
15
14
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
16
15
"github.com/golangci/golangci-lint/pkg/lint/linter"
17
16
"github.com/golangci/golangci-lint/pkg/result"
@@ -106,16 +105,6 @@ func (d depGuard) run(pass *analysis.Pass) ([]goanalysis.Issue, error) {
106
105
return resIssues , nil
107
106
}
108
107
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
-
119
108
type guardian struct {
120
109
* depguard.Depguard
121
110
pkgsWithErrorMessage map [string ]string
@@ -124,7 +113,7 @@ type guardian struct {
124
113
func newGuardian (settings * config.DepGuardSettings ) (* guardian , error ) {
125
114
var ignoreFileRules []string
126
115
for _ , rule := range settings .IgnoreFileRules {
127
- ignoreFileRules = append (ignoreFileRules , normalizePathInRegex (rule ))
116
+ ignoreFileRules = append (ignoreFileRules , fsutils . NormalizePathInRegex (rule ))
128
117
}
129
118
130
119
dg := & depguard.Depguard {
0 commit comments