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

image: NewUniform doesn't have documentation #38739

Closed
dmitshur opened this issue Apr 29, 2020 · 2 comments
Closed

image: NewUniform doesn't have documentation #38739

dmitshur opened this issue Apr 29, 2020 · 2 comments

Comments

@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Apr 29, 2020

The image.NewUniform function is exported and should have a comment per https://golang.org/doc/effective_go.html#commentary.

This came up when I realized it's not clear whether it's better to write image.NewUniform(c) or &image.Uniform{c}. I thought maybe image.NewUniform is deprecated like image.ZP, but that's not the case given it doesn't even have a comment. But it's not easy to feel confident using an exported method in the Go standard library when it's not documented.

https://blog.golang.org/image-draw prefers &image.Uniform{c} style, but it's also from 2011. NewUniform was renamed from NewColorImage in 2011, so it has existed for quite a while.

/cc @nigeltao @robpike

@nigeltao
Copy link
Contributor

@nigeltao nigeltao commented Apr 29, 2020

I agree that image.NewUniform needs a doc comment. I'll send out a (trivial) CL.

As for which of image.NewUniform(c) or &image.Uniform{c} is better, I think they're equally good, similar to io.LimitReader(r, n) and &io.LimitedReader{R:r, N:n}. I wouldn't mark either of them as deprecated. In hindsight, we could have only picked one, especially as composite literals are no longer a scary and new feature, but we can't change that now.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 29, 2020

Change https://golang.org/cl/230777 mentions this issue: image: add a NewUniform doc comment

Loading

@dmitshur dmitshur removed this from the Backlog milestone Apr 29, 2020
@dmitshur dmitshur added this to the Go1.15 milestone Apr 29, 2020
@gopherbot gopherbot closed this in 03efd42 Apr 29, 2020
xujianhai666 added a commit to xujianhai666/go-1 that referenced this issue May 21, 2020
Fixes golang#38739

Change-Id: I42b9b601e63ab8df69a0e5ce9bcabf75bb98d83e
Reviewed-on: https://go-review.googlesource.com/c/go/+/230777
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Apr 29, 2021
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