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

builtin: update documentation on builtin make #22764

Closed
AlexRamey opened this issue Nov 16, 2017 · 3 comments
Closed

builtin: update documentation on builtin make #22764

AlexRamey opened this issue Nov 16, 2017 · 3 comments

Comments

@AlexRamey
Copy link

@AlexRamey AlexRamey commented Nov 16, 2017

Please answer these questions before submitting your issue. Thanks!

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

1.9.2

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

darwin amd64

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

read the documentation on the make builtin (https://golang.org/pkg/builtin/#make)

What did you expect to see?

An explanation that specifying the capacity for a slice means that go will allocate an array big enough to hold that capacity without any resizing.
(After digging around the source code, I found this to be true)

What did you see instead?

Ambiguous comment:

//	Slice: The size specifies the length. The capacity of the slice is
//	equal to its length. A second integer argument may be provided to
//	specify a different capacity; it must be no smaller than the
//	length, so make([]int, 0, 10) allocates a slice of length 0 and
//	capacity 10.

Proposed Fix

Update this section of the comment to read:

//	Slice: The size specifies the length. The capacity of the slice is
//	equal to its length. A second integer argument may be provided to
//	specify a different capacity; it must be no smaller than the
//	length, so make([]int, 0, 10) allocates an underlying array of size 10
//	and returns a slice of length 0 and capacity 10 that is backed by this
//	underlying array.
@OneOfOne
Copy link
Contributor

@OneOfOne OneOfOne commented Nov 16, 2017

Language lawyers are getting to be almost as bad as real lawyers. /s

@ianlancetaylor ianlancetaylor changed the title Update Documentation on bulitin make builtin: update documentation on builtin make Nov 16, 2017
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 16, 2017

Change https://golang.org/cl/78335 mentions this issue: builtin: improve docs for make slice

@AlexRamey
Copy link
Author

@AlexRamey AlexRamey commented Nov 16, 2017

Thanks for addressing this

@gopherbot gopherbot closed this in ce68e1b Nov 18, 2017
@golang golang locked and limited conversation to collaborators Nov 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants