unmarshal float64

This commit is contained in:
Alexander Wang 2022-12-30 16:16:29 -08:00
parent fdcba4565e
commit a92e7211a7
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE

View file

@ -34,7 +34,15 @@ func (f *PluginSpecificFlag) AddToOpts(opts *xmain.Opts) {
case "string":
opts.String("", f.Name, "", f.Default.(string), f.Usage)
case "int64":
opts.Int64("", f.Name, "", f.Default.(int64), f.Usage)
var val int64
switch defaultType := f.Default.(type) {
case int64:
val = defaultType
case float64:
// json unmarshals numbers to float64
val = int64(defaultType)
}
opts.Int64("", f.Name, "", val, f.Usage)
}
}