chore: go mod tidy / vendor / make deps
This commit is contained in:
67
vendor/github.com/evertras/bubble-table/table/data.go
generated
vendored
Normal file
67
vendor/github.com/evertras/bubble-table/table/data.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
package table
|
||||
|
||||
import "time"
|
||||
|
||||
// This is just a bunch of data type checks, so... no linting here
|
||||
//
|
||||
//nolint:cyclop
|
||||
func asInt(data any) (int64, bool) {
|
||||
switch val := data.(type) {
|
||||
case int:
|
||||
return int64(val), true
|
||||
|
||||
case int8:
|
||||
return int64(val), true
|
||||
|
||||
case int16:
|
||||
return int64(val), true
|
||||
|
||||
case int32:
|
||||
return int64(val), true
|
||||
|
||||
case int64:
|
||||
return val, true
|
||||
|
||||
case uint:
|
||||
// #nosec: G115
|
||||
return int64(val), true
|
||||
|
||||
case uint8:
|
||||
return int64(val), true
|
||||
|
||||
case uint16:
|
||||
return int64(val), true
|
||||
|
||||
case uint32:
|
||||
return int64(val), true
|
||||
|
||||
case uint64:
|
||||
// #nosec: G115
|
||||
return int64(val), true
|
||||
|
||||
case time.Duration:
|
||||
return int64(val), true
|
||||
|
||||
case StyledCell:
|
||||
return asInt(val.Data)
|
||||
}
|
||||
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func asNumber(data any) (float64, bool) {
|
||||
switch val := data.(type) {
|
||||
case float32:
|
||||
return float64(val), true
|
||||
|
||||
case float64:
|
||||
return val, true
|
||||
|
||||
case StyledCell:
|
||||
return asNumber(val.Data)
|
||||
}
|
||||
|
||||
intVal, isInt := asInt(data)
|
||||
|
||||
return float64(intVal), isInt
|
||||
}
|
Reference in New Issue
Block a user