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

Closed
MaerF0x0 opened this issue Jun 12, 2020 · 3 comments
Closed

doc/go1.15: Vet notes typo #39566

MaerF0x0 opened this issue Jun 12, 2020 · 3 comments
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@MaerF0x0
Copy link

MaerF0x0 commented Jun 12, 2020

link: https://tip.golang.org/doc/go1.15#vet

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
@dmitshur
Copy link
Contributor

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.

@dmitshur dmitshur added Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 12, 2020
@ianlancetaylor
Copy link
Contributor

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

@MaerF0x0
Copy link
Author

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))

@golang golang locked and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants