let parse determine the base by prefix (allow octal, byte and hex representation)

This commit is contained in:
gutmet 2020-04-27 15:40:27 +02:00
parent 37a732e4e6
commit 6969cc9d96

View File

@ -44,7 +44,7 @@ var handlings = map[string]handling{
return strconv.FormatInt(int64(i), 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseInt(s, 10, 8)
i, err := strconv.ParseInt(s, 0, 8)
optPanic("conversion of "+s+" to int8 failed", err)
binaryWrite(w, bo, int8(i))
}},
@ -55,7 +55,7 @@ var handlings = map[string]handling{
return strconv.FormatUint(uint64(i), 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseUint(s, 10, 8)
i, err := strconv.ParseUint(s, 0, 8)
optPanic("conversion of "+s+" to uint8 failed", err)
binaryWrite(w, bo, uint8(i))
}},
@ -66,7 +66,7 @@ var handlings = map[string]handling{
return strconv.FormatInt(int64(i), 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseInt(s, 10, 16)
i, err := strconv.ParseInt(s, 0, 16)
optPanic("conversion of "+s+" to int16 failed", err)
binaryWrite(w, bo, int16(i))
}},
@ -77,7 +77,7 @@ var handlings = map[string]handling{
return strconv.FormatUint(uint64(i), 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseUint(s, 10, 16)
i, err := strconv.ParseUint(s, 0, 16)
optPanic("conversion of "+s+" to uint16 failed", err)
binaryWrite(w, bo, uint16(i))
}},
@ -88,7 +88,7 @@ var handlings = map[string]handling{
return strconv.FormatInt(int64(i), 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseInt(s, 10, 32)
i, err := strconv.ParseInt(s, 0, 32)
optPanic("conversion of "+s+" to int32 failed", err)
binaryWrite(w, bo, int32(i))
}},
@ -99,7 +99,7 @@ var handlings = map[string]handling{
return strconv.FormatUint(uint64(i), 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseUint(s, 10, 32)
i, err := strconv.ParseUint(s, 0, 32)
optPanic("conversion of "+s+" to uint32 failed", err)
binaryWrite(w, bo, uint32(i))
}},
@ -110,7 +110,7 @@ var handlings = map[string]handling{
return strconv.FormatInt(i, 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseInt(s, 10, 64)
i, err := strconv.ParseInt(s, 0, 64)
optPanic("conversion of "+s+" to int64 failed", err)
binaryWrite(w, bo, i)
}},
@ -121,7 +121,7 @@ var handlings = map[string]handling{
return strconv.FormatUint(i, 10)
},
func(w io.Writer, bo binary.ByteOrder, s string) {
i, err := strconv.ParseUint(s, 10, 64)
i, err := strconv.ParseUint(s, 0, 64)
optPanic("conversion of "+s+" to uint64 failed", err)
binaryWrite(w, bo, i)
}},