Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/cmd/godoc: some functions are not being indexed for search #8932
What steps will reproduce the problem? In a running godoc instance, search for ParseDuration What is the expected output? There should be a "Functions" heading at the top, with time.ParseDuration as a result within it. Clicking that link should take you to the documentation for time.ParseDuration. What do you see instead? There is no link to the time.ParseDuration documentation. Depending on the options that godoc was run with, you will see results with source code links under "Package-level declarations" and "Local declarations and uses". --- There are two factors that cause this condition to occur. First, the function in question returns a type defined in the same package. Second, the type being returned is defined in a different file from the function. In the example above, time.ParseDuration is defined in time/format.go, while the time.Duration type that it returns is defined in time/time.go. --- When godoc parses files to index the documentation, it currently parses each file individually. When time/format.go is parsed, godoc does not have the definition of time.Duration. Because of this, time.ParseDuration is then thrown away when we attempt to treat its like the methods on a type (which we do for functions which look like constructors). One solution would be to index the documentation on a package level instead of a file level.