Skip to content
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

runtime: bug with indexes while range in string #26542

Closed
jflenero opened this issue Jul 23, 2018 · 2 comments
Closed

runtime: bug with indexes while range in string #26542

jflenero opened this issue Jul 23, 2018 · 2 comments

Comments

@jflenero
Copy link

jflenero commented Jul 23, 2018

What version of Go are you using (go version)?

go version go1.10.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

https://play.golang.org/p/SGSiTfrzD3P

What did you expect to see?

We should expect a range of 37, as there are 37 characters in the string.

What did you see instead?

A range of 38, the special characters, in this case 'Ñ' make the indexes step further

@cuonglm
Copy link
Member

cuonglm commented Jul 23, 2018

I think it's intended, see https://blog.golang.org/strings

@myitcv
Copy link
Member

myitcv commented Jul 23, 2018

This is not a bug:

https://golang.org/ref/spec#String_types
https://golang.org/ref/spec#For_statements (see the bit about range clauses, specifically for strings)

@myitcv myitcv closed this as completed Jul 23, 2018
@golang golang locked and limited conversation to collaborators Jul 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants