-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/pkgsitec: factory functions are displayed in a way that can cause confusion #40223
Comments
Thanks for reporting. As @go101 pointed out via related issues, this is a heuristic and it's working as intended. |
@dmitshur There are many ways to save readers from confusing factory functions with struct receiver funcs. Here are three I thought of:
Will you please reconsider fixing this issue? EDIT: s/generator func/factory func/g @seankhliao I see that you downvoted my issue report. I think this means that you know something that I don't. Would you please explain it? |
My intention was to suggest we use #39813 for tracking improvements to the heuristic of when to consider a function as a "factory function". However, this issue seems slightly different, as it's about the way factory functions are displayed. Reopening so we can consider this further. /cc @julieqiu @griesemer |
@mleonhard I'm sorry that you had some confusion on this. Generally speaking, it's easy to recognize constructors because they have no receiver. Take for example the Cuelang Godoc, in particular the That said, I could see introducing a very small change to call a little more attention to these methods. Perhaps if the circle next to them was filled rather than hollow? I think that would make it easier to spot whilst scanning the overall package, without negatively affecting what seems to be a long-lasting and battle-tested structure. (...Hm, I realize now that golang.org/pkg is actually a little different from godoc.org, for example missing the bullet, but it could be added.) |
In the case of |
At this point, I don't think it's something that will change. |
What did you do?
My golang program needs to find out if a path refers to an existing directory. I need to find out how to do that. Here's what I did:
golang isdir
isdir
.type FileInfo
. It contains anIsDir()
function. The description says "A FileInfo describes a file and is returned by Stat and Lstat."Stat
function. Foundtype File
with aStat()
function. Unfortunately, to create aFile
struct, one must actually create a normal file on the filesystem.Stat(string)
function indented undertype FileInfo
in the index. Clicked on it. This is the same struct that I just looked at. Where is the top-levelStat
method?fileinfo, err := os.Stat("temp.txt")
.Stat
top-level function. This is so strange.Stat
function is indented undertype FileInfo
but it's not actually a method on that struct:What did you expect to see?
I expected to see
func Stat(name string) (FileInfo, error)
unindented, in the top section of the index with the module-level functions. Like this:What did you see instead?
I saw
func Stat(name string) (FileInfo, error)
appearing out of order with the other top-level functions inos
, indented undertype FileInfo
as if it is a method ofFileInfo
.The text was updated successfully, but these errors were encountered: