Skip to content

Go1.12 strings.Map breaks package usage of strings.ToUpper and strings.ToLower #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cybrcodr opened this issue Jan 9, 2019 · 0 comments · Fixed by #31
Closed

Go1.12 strings.Map breaks package usage of strings.ToUpper and strings.ToLower #26

cybrcodr opened this issue Jan 9, 2019 · 0 comments · Fixed by #31

Comments

@cybrcodr
Copy link

cybrcodr commented Jan 9, 2019

Go1.12 CL https://golang.org/cl/131495 will break this package's use of upper() and lower() calls. This is exhibited in the following test failure ...

$ go version
go version go1.12beta1 linux/386
$ go test
--- FAIL: TestToGoName (0.03s)
    util_test.go:66:
                Error Trace:    util_test.go:66
                Error:          Not equal:
                                expected: "X日本語sample2Text"
                                actual  : "X�\xbf\xbd��本語sample2Text"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -X日本語sample2Text
                                +X�����本語sample2Text
                Test:           TestToGoName
    util_test.go:66:
                Error Trace:    util_test.go:66
                Error:          Not equal:
                                expected: "X日本語findThingByID"
                                actual  : "X�\xbf\xbd��本語findThingByID"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -X日本語findThingByID
                                +X�����本語findThingByID
                Test:           TestToGoName
FAIL
exit status 1

The issue has to do with this package passing in str[:1] to upper() and lower() assuming that slicing out the first byte is a valid unicode character and if not, the calls to strings.ToUpper or strings.ToLower will return back the same byte and hence can be reused. The new behavior of strings.ToUpper and strings.ToLower returns back utf8.RuneError if byte is not a valid unicode character instead and breaks the logic in callers when concatenating to another string slice.

For example -- https://github.com/go-openapi/swag/blob/v0.18.0/util.go#L332-L337.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant