go-admin
go-admin copied to clipboard
[BUG] InfoPanel的FieldDate参数没有传递
bug 描述 [详细地描述 bug,让大家都能理解]
InfoPanel的FieldDate函数的参数format没有传递,会造成panic
复现步骤 [清晰描述复现步骤,让别人也能看到问题]
- 在任何生成的info panel中,使用FieldDate
复现代码 [提供可复现的代码,仓库,或线上示例]
https://github.com/GoAdminGroup/go-admin/blob/master/template/types/info.go Line1125-1128
func (i *InfoPanel) FieldDate(format string) *InfoPanel {
i.addDisplayChains(displayFnGens["date"].Get())
return i
}
https://github.com/GoAdminGroup/go-admin/blob/master/template/types/display/date.go Line18-25
func (d *Date) Get(args ...interface{}) types.FieldFilterFn {
return func(value types.FieldModel) interface{} {
format := args[0].(string)
ts, _ := strconv.ParseInt(value.Value, 10, 64)
tm := time.Unix(ts, 0)
return tm.Format(format)
}
}
可以看到format没有传递到Get方法中,args是空的slice,而Get方法会取第一个参数,此时数组越界,造成panic