Create some subroutines and test

This commit is contained in:
Bel LaPointe
2021-03-14 23:29:50 -05:00
parent 60adca804b
commit d79721b760
8 changed files with 578 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
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)
}