@@ -125,7 +125,7 @@ type ProtoTrace struct {
125
125
func (pt * ProtoTrace ) UnmarshalText (b []byte ) error {
126
126
lines := strings .Split (string (b ), "\n " )
127
127
for _ , line := range lines {
128
- if matches , matched := checkForDataPathActions ( line ); matched {
128
+ if matches , matched := checkMatch ( datapathActionsRegexp , line ); matched {
129
129
// first index is always the left most match, following
130
130
// are the actual matches
131
131
pt .DataPathActions = & dataPathActions {
@@ -135,7 +135,7 @@ func (pt *ProtoTrace) UnmarshalText(b []byte) error {
135
135
continue
136
136
}
137
137
138
- if matches , matched := checkForInputFlow ( line ); matched {
138
+ if matches , matched := checkMatch ( initialFlowRegexp , line ); matched {
139
139
flow := & DataPathFlows {}
140
140
err := flow .UnmarshalText ([]byte (matches [1 ]))
141
141
if err != nil {
@@ -146,7 +146,7 @@ func (pt *ProtoTrace) UnmarshalText(b []byte) error {
146
146
continue
147
147
}
148
148
149
- if matches , matched := checkForFinalFlow ( line ); matched {
149
+ if matches , matched := checkMatch ( finalFlowRegexp , line ); matched {
150
150
flow := & DataPathFlows {}
151
151
err := flow .UnmarshalText ([]byte (matches [1 ]))
152
152
if err != nil {
@@ -157,19 +157,19 @@ func (pt *ProtoTrace) UnmarshalText(b []byte) error {
157
157
continue
158
158
}
159
159
160
- if _ , matched := checkForMegaFlow ( line ); matched {
160
+ if _ , matched := checkMatch ( megaFlowRegexp , line ); matched {
161
161
continue
162
162
}
163
163
164
- if _ , matched := checkForTraceStart ( line ); matched {
164
+ if _ , matched := checkMatch ( traceStartRegexp , line ); matched {
165
165
continue
166
166
}
167
167
168
- if _ , matched := checkForTraceFlow ( line ); matched {
168
+ if _ , matched := checkMatch ( traceFlowRegexp , line ); matched {
169
169
continue
170
170
}
171
171
172
- if matches , matched := checkForTraceAction ( line ); matched {
172
+ if matches , matched := checkMatch ( traceActionRegexp , line ); matched {
173
173
pt .FlowActions = append (pt .FlowActions , matches [1 ])
174
174
continue
175
175
}
@@ -178,62 +178,8 @@ func (pt *ProtoTrace) UnmarshalText(b []byte) error {
178
178
return nil
179
179
}
180
180
181
- func checkForDataPathActions (s string ) ([]string , bool ) {
182
- matches := datapathActionsRegexp .FindStringSubmatch (s )
183
- if len (matches ) == 0 {
184
- return matches , false
185
- }
186
-
187
- return matches , true
188
- }
189
-
190
- func checkForInputFlow (s string ) ([]string , bool ) {
191
- matches := initialFlowRegexp .FindStringSubmatch (s )
192
- if len (matches ) == 0 {
193
- return matches , false
194
- }
195
-
196
- return matches , true
197
- }
198
-
199
- func checkForFinalFlow (s string ) ([]string , bool ) {
200
- matches := finalFlowRegexp .FindStringSubmatch (s )
201
- if len (matches ) == 0 {
202
- return matches , false
203
- }
204
-
205
- return matches , true
206
- }
207
-
208
- func checkForMegaFlow (s string ) ([]string , bool ) {
209
- matches := megaFlowRegexp .FindStringSubmatch (s )
210
- if len (matches ) == 0 {
211
- return matches , false
212
- }
213
-
214
- return matches , true
215
- }
216
-
217
- func checkForTraceStart (s string ) ([]string , bool ) {
218
- matches := traceStartRegexp .FindStringSubmatch (s )
219
- if len (matches ) == 0 {
220
- return matches , false
221
- }
222
-
223
- return matches , true
224
- }
225
-
226
- func checkForTraceFlow (s string ) ([]string , bool ) {
227
- matches := traceFlowRegexp .FindStringSubmatch (s )
228
- if len (matches ) == 0 {
229
- return matches , false
230
- }
231
-
232
- return matches , true
233
- }
234
-
235
- func checkForTraceAction (s string ) ([]string , bool ) {
236
- matches := traceActionRegexp .FindStringSubmatch (s )
181
+ func checkMatch (re * regexp.Regexp , s string ) ([]string , bool ) {
182
+ matches := re .FindStringSubmatch (s )
237
183
if len (matches ) == 0 {
238
184
return matches , false
239
185
}
0 commit comments