@@ -2,7 +2,6 @@ package sflow
2
2
3
3
import (
4
4
"bytes"
5
- "errors"
6
5
"fmt"
7
6
8
7
"github.com/cloudflare/goflow/v3/decoders/utils"
@@ -214,10 +213,10 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
214
213
return flowRecord , err
215
214
}
216
215
if int (extendedGateway .ASPathLength ) > payload .Len ()- 4 {
217
- return flowRecord , errors . New ( fmt .Sprintf ( "Invalid AS path length: %v. " , extendedGateway .ASPathLength ) )
216
+ return flowRecord , fmt .Errorf ( "invalid AS path length: %v" , extendedGateway .ASPathLength )
218
217
}
219
218
if extendedGateway .ASPathLength > MAX_AS_PATH_LENGTH {
220
- return flowRecord , fmt .Errorf ("Invalid AS path length: %d" , extendedGateway .ASPathLength )
219
+ return flowRecord , fmt .Errorf ("invalid AS path length: %d" , extendedGateway .ASPathLength )
221
220
}
222
221
asPath = make ([]uint32 , extendedGateway .ASPathLength )
223
222
if len (asPath ) > 0 {
@@ -234,11 +233,11 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
234
233
return flowRecord , err
235
234
}
236
235
if int (extendedGateway .CommunitiesLength ) > payload .Len ()- 4 {
237
- return flowRecord , errors . New ( fmt .Sprintf ( "Invalid Communities length: %v. " , extendedGateway .CommunitiesLength ) )
236
+ return flowRecord , fmt .Errorf ( "invalid Communities length: %v" , extendedGateway .CommunitiesLength )
238
237
}
239
238
240
239
if extendedGateway .CommunitiesLength > MAX_COMMUNITIES_LENGTH {
241
- return flowRecord , fmt .Errorf ("Invalid communities length: %d" , extendedGateway .CommunitiesLength )
240
+ return flowRecord , fmt .Errorf ("invalid communities length: %d" , extendedGateway .CommunitiesLength )
242
241
}
243
242
communities := make ([]uint32 , extendedGateway .CommunitiesLength )
244
243
if len (communities ) > 0 {
@@ -255,7 +254,7 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
255
254
256
255
flowRecord .Data = extendedGateway
257
256
default :
258
- return flowRecord , errors . New ( fmt .Sprintf ( "Unknown data format %v. " , (* header ).DataFormat ) )
257
+ return flowRecord , fmt .Errorf ( "unknown data format %v" , (* header ).DataFormat )
259
258
}
260
259
return flowRecord , nil
261
260
}
@@ -301,7 +300,7 @@ func DecodeSample(header *SampleHeader, payload *bytes.Buffer) (interface{}, err
301
300
}
302
301
recordsCount = flowSample .FlowRecordsCount
303
302
if recordsCount > MAX_FLOW_RECORDS {
304
- return flowSample , fmt .Errorf ("Invalid number of flows records: %d" , recordsCount )
303
+ return flowSample , fmt .Errorf ("invalid number of flows records: %d" , recordsCount )
305
304
}
306
305
flowSample .Records = make ([]FlowRecord , recordsCount )
307
306
sample = flowSample
@@ -316,7 +315,7 @@ func DecodeSample(header *SampleHeader, payload *bytes.Buffer) (interface{}, err
316
315
}
317
316
318
317
if recordsCount > MAX_SAMPLES_PER_PACKET {
319
- return flowSample , fmt .Errorf ("Invalid number of samples: %d" , recordsCount )
318
+ return flowSample , fmt .Errorf ("invalid number of samples: %d" , recordsCount )
320
319
}
321
320
counterSample .Records = make ([]CounterRecord , recordsCount )
322
321
sample = counterSample
0 commit comments