3 ms·
The strconv function simply acts in the same manner as the language does, see https://play.golang.org/p/rg0VwhCDVB_C https://play.golang.org/p/rg0VwhCDVB_C The
by zcdopizocioics 8y ago
The strconv function simply acts in the same manner as the language does, see https://play.golang.org/p/rg0VwhCDVB_C https://play.golang.org/p/rg0VwhCDVB_C
The idea for strconv originates in c (see atoi etc), and c also has 0-octal notation.
Go is simply mimicing c in this regard.
> What was the Golang team thinking?!
They were helping you not misuse the function, as you are doing in your example (you are trying to parse strings containing invalid number representations as integers).
- kaushalmodi 8y agoThanks for your comment. It kind of makes a little sense now. I just wished the octals needed a stricter prefix like "0o" as they are not very common compared to decimal and hex (in my experience at least). The way Python casts strings with leading zeros makes more sense to me. Later I'll update the post with your feedback. Thanks.