What is the URL of the page with the issue?
https://pkg.go.dev/log/slog#pkg-variables
What is your user agent?
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Screenshot
What did you do?
During code review, I wanted to share a colleague a link to the newly added DiscardHandler. While searching in my browser for it, I quickly learned that it was a variable and I wanted to send him a link to the variable so I went to the variable section but that was empty.
What did you see happen?
I was expecting to see DiscardHandler in the list of variables. Also i could not find it in the object tree.
What did you expect to see?
I expected to see the variable mentioned under the Variables section or somewhere else in the object tree.
Now that I had a closer look also variables in other packages are not consistently added to the variables section (e.g net/http/DefaultTransport) . Maybe the policy is to only list variables that 'deserve' to be mentioned in the variables list but sometimes (like now) I found this confusing.
As a suggestion variables could also be added under the types header so In this case it would go under Handler (https://pkg.go.dev/log/slog#Handler) like also is done for constructors.
Comment From: seankhliao
Like functions that instantiate types declared in the package, they're listed with the type, and we don't duplicate them to other sections (that would be too confusing for something to be listed multiple times).
Comment From: gabyhelp
Related Issues
- x/pkgsite: missing "added in version" for slog.DiscardHandler #73032 (closed)
- log/slog: ExampleDiscardHandler not shown on pkg site #70782 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: ArnoSen
okay, thanks for the feedback. Just want to mention that as a reader, I am missing the awareness that certain variables exist. I recently found out there is io.Discard which is also buried deep in the documentation and not easily found when looking for a solution to an acute need. Maybe if you get similar remarks from other users as well, this issue will help in making the available variables easier to identify.
On the other hand, now I know better now where to look for so you reply is most useful. Thanks!
Comment From: zigo101
This is a long-time design problem that it looks Go team is quite proud of.
See https://github.com/golang/go/issues/28006, https://github.com/golang/go/issues/38666, https://github.com/golang/go/issues/39813, https://github.com/golang/go/issues/40223, https://github.com/golang/go/issues/40927, and maybe more.
This is an important reason why Golds was developed.