Files
cards/src/game/rule/operation/convert.go
2021-03-14 23:29:50 -05:00

23 lines
329 B
Go

package operation
import (
"fmt"
"strconv"
)
func convertNumber(v interface{}) int {
s := fmt.Sprint(v)
v2, _ := strconv.ParseFloat(s, 64)
return int(v2)
}
func convertString(v interface{}) string {
switch v.(type) {
case string:
return v.(string)
case []byte:
return string(v.([]byte))
}
return fmt.Sprint(v)
}