Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
strings: broken backward compatibility in 1.12 #31121
What version of Go are you using (
Thanks for the report. I'm tentatively putting this into the 1.13 milestone, pending investigation.
It would be nice to have a self-contained example that shows how the new behaviour is different from the old, and why this is causing tests breakage.
cc @martisch, author of that CL, in the meantime.
The difference is how invalid UTF8 sequences are treated and this is WAI and wont change back. They now will always be converted to RuneRrror runes. Before they were only converted to RuneError runes when there also was another change e.g. upper case character converted to lower case. Which was inconsistent and a bug. The new behaviour is consistent and always converts invalid sequences.
For the noted examples such as https://github.com/julienschmidt/httprouter a bug was filed before go1.12 release that the tests will fail as the package assumes the old behaviour. julienschmidt/httprouter#263
Some of the problems seen with package tests breaking happen when the packages incorrectly assume that they can convert strings byte by byte which the new behaviour converts into RuneErrors for non ASCII characters and this only worked accidentally before when not needing to convert part of the string with invalid sequences. For example: go-openapi/swag#26