Re:Experience report on a large Python-to-Go translation
by AnimalMuppet on Tuesday February 11, 2020 @11:44PM
(#22305875)
I wish he had been a bit more explicit there, TBH. What's better about Go strings?
[ Parent
| on HN ]
Re:Experience report on a large Python-to-Go translation
by Izkata on Wednesday February 12, 2020 @12:37AM
(#22306115)
Skimming over a post from a quick search [0], it looks like Go strictly uses byte strings and manipulates them with various keywords and functions. No encoding/decoding between byte strings (and picking an encoding) and unicode strings like in python.
Re:Experience report on a large Python-to-Go translation
by rauhl on Wednesday February 12, 2020 @08:23AM
(#22308563)
I think that’s not really the right way to put it. Rather, go offers UTF-8 strings and byte slices, with a simple typecast in either way, with various keywords and functions to DTRT to each. One still must worry about encoding & decoding if one doesn’t want UTF-8, and one must worry about invalid UTF-8 in a byte slice when casting, but in general Go does what one would expect with a minimum of fuss.
Re:Experience report on a large Python-to-Go translation
by 0xjnml on Thursday February 13, 2020 @12:31PM
(#22319566)
Go strings are just a sequence of bytes in no particular encoding, i.e they can contain arbitrary data. Converting strings to byte slices and vice versa works always without ever changing a single bit.