Merge pull request #115827 from borgerli/fix/construct-float

add missed case for float types
This commit is contained in:
Kubernetes Prow Robot 2023-02-22 22:07:06 -08:00 committed by GitHub
commit 3ce7cdda1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,6 +173,10 @@ func fill(dataString string, dataInt int, t reflect.Type, v reflect.Value, fillF
// use Convert to set into int alias types and different int widths correctly
v.Set(reflect.ValueOf(dataInt).Convert(t))
case reflect.Float32, reflect.Float64:
// use Convert to set into float types
v.Set(reflect.ValueOf(float32(dataInt) + 0.5).Convert(t))
default:
panic(fmt.Errorf("unhandled type %v in field %s", t, dataString))
}