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

doc/go1.15: Vet notes typo #39566

MaerF0x0 opened this issue Jun 12, 2020 · 3 comments

doc/go1.15: Vet notes typo #39566

MaerF0x0 opened this issue Jun 12, 2020 · 3 comments


Copy link

@MaerF0x0 MaerF0x0 commented Jun 12, 2020


What did you expect to see?

Allow string conversion from byte slice

to only permit string(x) for integer x when the type of x is rune or byte slice.

What did you see instead?

We are considering prohibiting the conversion in a future release of Go. That is, the language would change to only permit string(x) for integer x when the type of x is rune or byte. Such a language change would not be backward compatible. We are using this vet check as a first trial step toward changing the language.

I didnt know where to submit a CL

@MaerF0x0 MaerF0x0 changed the title x/website: x/website: 1.15 Vet notes typo Jun 12, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 12, 2020
@dmitshur dmitshur changed the title x/website: 1.15 Vet notes typo doc/go1.15: Vet notes typo Jun 12, 2020
Copy link

@dmitshur dmitshur commented Jun 12, 2020

Thanks for reporting.

My understanding is that the current text is correct and intentional. It refers to conversions like string(x) where x is not a slice type, but rather a rune or byte. Conversions of []byte to string is not the topic being discussed; that's out of scope of #3939.

I'll let @ianlancetaylor who authored CL 234517 confirm. If it turns out more people find the current wording confusing, we can try to improve it.

Copy link

@ianlancetaylor ianlancetaylor commented Jun 12, 2020

Yes, the existing text is correct. Thanks for asking about it.

Copy link

@MaerF0x0 MaerF0x0 commented Jun 13, 2020

I see, yes. Prompted by your notes as I read it closer I came to understand the text block is only talking about for integer x. My incorrect reading of text had me concerned I'd lose the ability to convert []byte when I want to print as strings, something like:

data, _ := json.Marshal(map[string]interface{}{"JSON": "Yes"})
// data is []byte
fmt.Println("json is", string(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.