@@ -24,11 +24,11 @@ const (
24
24
25
25
type Parser struct {
26
26
// Meant to be passed via New()
27
- path , ignore string
28
- ignoreTests , matchConstant bool
29
- minLength , minOccurrences int
30
- numberMin , numberMax int
31
- excludeTypes map [Type ]bool
27
+ path , ignore , ignoreStrings string
28
+ ignoreTests , matchConstant bool
29
+ minLength , minOccurrences int
30
+ numberMin , numberMax int
31
+ excludeTypes map [Type ]bool
32
32
33
33
supportedTokens []token.Token
34
34
@@ -39,7 +39,7 @@ type Parser struct {
39
39
40
40
// New creates a new instance of the parser.
41
41
// This is your entry point if you'd like to use goconst as an API.
42
- func New (path , ignore string , ignoreTests , matchConstant , numbers bool , numberMin , numberMax , minLength , minOccurrences int , excludeTypes map [Type ]bool ) * Parser {
42
+ func New (path , ignore , ignoreStrings string , ignoreTests , matchConstant , numbers bool , numberMin , numberMax , minLength , minOccurrences int , excludeTypes map [Type ]bool ) * Parser {
43
43
supportedTokens := []token.Token {token .STRING }
44
44
if numbers {
45
45
supportedTokens = append (supportedTokens , token .INT , token .FLOAT )
@@ -48,6 +48,7 @@ func New(path, ignore string, ignoreTests, matchConstant, numbers bool, numberMi
48
48
return & Parser {
49
49
path : path ,
50
50
ignore : ignore ,
51
+ ignoreStrings : ignoreStrings ,
51
52
ignoreTests : ignoreTests ,
52
53
matchConstant : matchConstant ,
53
54
minLength : minLength ,
@@ -98,6 +99,16 @@ func (p *Parser) ProcessResults() {
98
99
delete (p .strs , str )
99
100
}
100
101
102
+ if p .ignoreStrings != "" {
103
+ match , err := regexp .MatchString (p .ignoreStrings , str )
104
+ if err != nil {
105
+ log .Println (err )
106
+ }
107
+ if match {
108
+ delete (p .strs , str )
109
+ }
110
+ }
111
+
101
112
// If the value is a number
102
113
if i , err := strconv .ParseInt (str , 0 , 0 ); err == nil {
103
114
if p .numberMin != 0 && i < int64 (p .numberMin ) {
0 commit comments