mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 03:54:59 +08:00
chore (refactoring): support for edge case
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NewBool(t bool) *bool {
|
||||
@ -62,6 +63,15 @@ func NewStringFromInterface(val interface{}) string {
|
||||
return val.(string)
|
||||
case float64:
|
||||
return fmt.Sprintf("%d", int64(val.(float64)))
|
||||
case bool:
|
||||
return fmt.Sprintf("%t", val.(bool))
|
||||
case []interface{}:
|
||||
list := val.([]interface{})
|
||||
strSlice := make([]string, len(list))
|
||||
for i, el := range list {
|
||||
strSlice[i] = NewStringFromInterface(el)
|
||||
}
|
||||
return strings.Join(strSlice, ",")
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user