Skip to content

Commit 792e53f

Browse files
fix: ensure we convert the uint type (#2626)
1 parent e7749cf commit 792e53f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/common/variadic/uint32OrHash.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func NewUint32OrHash(value interface{}) (*Uint32OrHash, error) {
2323
return &Uint32OrHash{
2424
value: uint32(v),
2525
}, nil
26+
case uint:
27+
return &Uint32OrHash{
28+
value: uint32(v),
29+
}, nil
2630
case uint32:
2731
return &Uint32OrHash{
2832
value: v,
@@ -98,6 +102,7 @@ func (x *Uint32OrHash) IsUint32() bool {
98102
if x == nil {
99103
return false
100104
}
105+
101106
_, is := x.value.(uint32)
102107
return is
103108
}

lib/common/variadic/uint32OrHash_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func TestNewUint32OrHash(t *testing.T) {
2525
require.NoError(t, err)
2626
require.Equal(t, uint32(num), res.Value())
2727

28+
res, err = NewUint32OrHash(uint(num))
29+
require.NoError(t, err)
30+
require.Equal(t, uint32(num), res.Value())
31+
2832
res, err = NewUint32OrHash(uint32(num))
2933
require.NoError(t, err)
3034
require.Equal(t, uint32(num), res.Value())

0 commit comments

Comments
 (0)