Fix string to int64 conversion for SNMP input (#7407)
This commit is contained in:
parent
8957032790
commit
1bb436e8a8
|
@ -804,9 +804,9 @@ func fieldConvert(conv string, v interface{}) (interface{}, error) {
|
||||||
case uint64:
|
case uint64:
|
||||||
v = int64(vt)
|
v = int64(vt)
|
||||||
case []byte:
|
case []byte:
|
||||||
v, _ = strconv.Atoi(string(vt))
|
v, _ = strconv.ParseInt(string(vt), 10, 64)
|
||||||
case string:
|
case string:
|
||||||
v, _ = strconv.Atoi(vt)
|
v, _ = strconv.ParseInt(vt, 10, 64)
|
||||||
}
|
}
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -694,6 +694,8 @@ func TestFieldConvert(t *testing.T) {
|
||||||
{uint64(123), "float(3)", float64(0.123)},
|
{uint64(123), "float(3)", float64(0.123)},
|
||||||
{"123", "int", int64(123)},
|
{"123", "int", int64(123)},
|
||||||
{[]byte("123"), "int", int64(123)},
|
{[]byte("123"), "int", int64(123)},
|
||||||
|
{"123123123123", "int", int64(123123123123)},
|
||||||
|
{[]byte("123123123123"), "int", int64(123123123123)},
|
||||||
{float32(12.3), "int", int64(12)},
|
{float32(12.3), "int", int64(12)},
|
||||||
{float64(12.3), "int", int64(12)},
|
{float64(12.3), "int", int64(12)},
|
||||||
{int(123), "int", int64(123)},
|
{int(123), "int", int64(123)},
|
||||||
|
|
Loading…
Reference in New Issue