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
x/website, x/pkgsite, x/tools/cmd/godoc: context.Context.Value isn't present in index, and comment on ordering of functions that return a type #37674
Comments
It's true that the I don't see where this applies in the The Can you clarify if I'm misunderstanding your point about the |
To me, package level functions shouldn't be indented under anything. I know it doesn't show a receiver for it but my first read is that there's a type called Conn and it has a function called Dial. Also, I understand and agree that it works like a constructor but in a language without formal constructors I wouldn't expect the documentation to be organized like it is a constructor. |
Thanks for your feedback. Putting functions that return a specific type under that type is a feature that has existed for many years now. To make progress here, need to investigate what were the trade-offs considered when choosing to implement this feature. Another factor is that many Go users are used to the current behavior, so a change would be costly. Any potential benefits of a change need to be weighed against the cost of doing it. There may be some existing work related to the design of the index on pkg.go.dev (/cc @julieqiu) which can take this issue into account. Labeling as NeedsInvestigation. /cc @griesemer @julieqiu |
The logic behind net.Dial makes sense eventually, and I believe new go people can figure that out and run with it. But when it comes to context.Value(...), I'm less sure what the reasoning is. |
I agree that not including the It's worth taking into account that the Compare it to a package like Including its Similarly, the |
Agreed. As soon as you grok that the "constructor" methods are top of the list under a type in the Index, it becomes very valuable. You look at a type, you can see how to make one and how to use it. I would venture that any intention to change this bears the burden of proof that Gophers at large would find this beneficial. |
Recently I've been working with a developer that's new to go and is using the documentation to get up to speed. There have been a couple things missing from the index of some documentation pages.
For example, https://golang.org/pkg/context has no documentation around
(context) Value(key interface{}) interface{}
. It's shown in an example and mentioned in the interface undertype Context
but the function feels too important not to be listed in the index or have its own paragraph detailing it.There's a similar situation with
Dial(network string, address string) (net.Conn, error)
in thenet
package. It's talked about in the overview but missing from the index.The text was updated successfully, but these errors were encountered: