Skip to content

Commit 4ac7fc4

Browse files
committed
new(event): Introduce IsNumber method for param
The method checks if the event param stores the integer (unsigned/signed) value type.
1 parent bd8608f commit 4ac7fc4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pkg/event/param.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ package event
2020

2121
import (
2222
"fmt"
23+
"net"
24+
"reflect"
25+
"sort"
26+
"strings"
27+
"time"
28+
2329
"github.com/rabbitstack/fibratus/pkg/fs"
2430
"github.com/rabbitstack/fibratus/pkg/network"
2531
"github.com/rabbitstack/fibratus/pkg/util/key"
2632
"github.com/rabbitstack/fibratus/pkg/util/va"
2733
"golang.org/x/text/cases"
2834
"golang.org/x/text/language"
29-
"net"
30-
"reflect"
31-
"sort"
32-
"strings"
33-
"time"
3435

3536
"github.com/rabbitstack/fibratus/pkg/errors"
3637
"github.com/rabbitstack/fibratus/pkg/event/params"
@@ -99,6 +100,12 @@ type Param struct {
99100
Enum ParamEnum `json:"enum"`
100101
}
101102

103+
// IsNumber determines if the parameter stores the integer value type.
104+
func (p Param) IsNumber() bool {
105+
return p.Type == params.Int8 || p.Type == params.Int16 || p.Type == params.Int32 || p.Type == params.Int64 ||
106+
p.Type == params.Uint8 || p.Type == params.Uint16 || p.Type == params.Uint32 || p.Type == params.Uint64
107+
}
108+
102109
// CaptureType returns the event type saved inside the capture file.
103110
// Captures usually override the type of the parameter to provide
104111
// consistent replay experience. For example, the file path param

0 commit comments

Comments
 (0)