Skip to content

Commit

Permalink
proto: convert integer to rune before converting to string (#1210)
Browse files Browse the repository at this point in the history
Go 1.15 introduced a new `go vet` warning
(https://golang.org/doc/go1.15#vet) for conversions of the form
`string(x)` where `x` is an integer type other than `rune` or `byte`.
This warning is enabled by default when running `go test`. As a
consequence, running `go test github.com/golang/protobuf/proto`
results in a build failure prior to this commit.
  • Loading branch information
saser committed Sep 24, 2020
1 parent d04d7b1 commit 3860b27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion proto/text_decode.go
Expand Up @@ -765,7 +765,7 @@ func unescape(s string) (ch string, tail string, err error) {
if i > utf8.MaxRune {
return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss)
}
return string(i), s, nil
return string(rune(i)), s, nil
}
return "", "", fmt.Errorf(`unknown escape \%c`, r)
}
Expand Down

0 comments on commit 3860b27

Please sign in to comment.