1
+ // Package tinyHelper as wrappers - shorters
2
+ // with the some helping functions
1
3
package tinyHelper
2
4
3
5
import (
@@ -49,7 +51,7 @@ func toBaseOther(v, base int) string {
49
51
// ToBase[GeneralTypes](T, int, int, ...int) string
50
52
// Wrapper for convert from one base to another base
51
53
func ToBase [T GeneralTypes ](val T , from , to int , prefixNulls ... int ) (nv string ) {
52
- to10 := ToInt (val , from )
54
+ to10 := ToInt (val , from )
53
55
nv = ToStr (to10 )
54
56
prx := ""
55
57
if prefixNulls != nil || len (prefixNulls ) > 0 {
@@ -63,7 +65,7 @@ func ToBase[T GeneralTypes](val T, from, to int, prefixNulls ...int) (nv string)
63
65
case 16 :
64
66
nv = fmt .Sprintf ("%" + prfBase + prx + Base16 , to10 )
65
67
default :
66
- nv = fmt .Sprintf ("%" + prfBase + prx + "v" , toBaseOther (to10 , to ))
68
+ nv = fmt .Sprintf ("%" + prfBase + prx + "v" , toBaseOther (to10 , to ))
67
69
}
68
70
return
69
71
}
@@ -82,15 +84,15 @@ func ToNum[T1 NumsTypes, T GeneralTypes](val T, base ...int) T1 {
82
84
// Del prefix. Parse values with prefix 0b, 0o, 0x works if base '0' value in parameter.
83
85
if len (f ) >= 2 {
84
86
switch {
85
- case f [:2 ] == (prfBase + Base02 ) && parBase == 16 :
86
- case f [:2 ] == (prfBase + Base02 ):
87
- parBase = 2
87
+ case f [:2 ] == (prfBase + Base02 ) && parBase == 16 :
88
+ case f [:2 ] == (prfBase + Base02 ):
89
+ parBase = 2
88
90
f = f [2 :]
89
91
case f [:2 ] == (prfBase + Base08 ):
90
- parBase = 8
92
+ parBase = 8
91
93
f = f [2 :]
92
94
case f [:2 ] == (prfBase + Base16 ):
93
- parBase = 16
95
+ parBase = 16
94
96
f = f [2 :]
95
97
}
96
98
}
0 commit comments