You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
595 B
28 lines
595 B
3 years ago
|
package proto
|
||
|
|
||
|
import "strconv"
|
||
|
|
||
|
func bytesToString(b []byte) string {
|
||
|
return string(b)
|
||
|
}
|
||
|
|
||
|
func stringToBytes(s string) []byte {
|
||
|
return []byte(s)
|
||
|
}
|
||
|
|
||
|
func atoi(b []byte) (int, error) {
|
||
|
return strconv.Atoi(bytesToString(b))
|
||
|
}
|
||
|
|
||
|
func parseInt(b []byte, base int, bitSize int) (int64, error) {
|
||
|
return strconv.ParseInt(bytesToString(b), base, bitSize)
|
||
|
}
|
||
|
|
||
|
func parseUint(b []byte, base int, bitSize int) (uint64, error) {
|
||
|
return strconv.ParseUint(bytesToString(b), base, bitSize)
|
||
|
}
|
||
|
|
||
|
func parseFloat(b []byte, bitSize int) (float64, error) {
|
||
|
return strconv.ParseFloat(bytesToString(b), bitSize)
|
||
|
}
|