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

x/tools/cmd/godoc: first return value with an unqualified imported type not showing up in documentation output #15107

Closed
mikeatlas opened this issue Apr 4, 2016 · 7 comments

Comments

Projects
None yet
4 participants
@mikeatlas
Copy link

commented Apr 4, 2016

  1. What version of Go are you using (go version)?
    go version go1.5.3 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mikeatlas/gopath"
GORACE=""
GOROOT="/home/mikeatlas/golang/go"
GOTOOLDIR="/home/mikeatlas/golang/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?

Using godoc -http=:6060 to generate live documentation, I seem to have an edge case that does not appear to make any sense. Function return values with an imported type without a qualifier as the first value do not appear in documentation, with return order being the only difference and the imported type without a qualifier as the first return value will cause the function to not show up in documentation output HTML. An example is as follows:

package xyz

import . "qpackage/q"

// TestFn is a test function
func TestFn(input string) (Q, error) {}

// TestFnX is a test function
func TestFnX(input string) (error, Q) {}

In this example, only TestFnX appears in the documentation output. However, if I qualify the imported package type, both work:

package xyz

import q "qpackage/q"

// TestFn is a test function
func TestFn(input string) (q.Q, error) {}

// TestFnX is a test function
func TestFnX(input string) (error, q.Q) {}

In this example, both TestFn and TestFnX appear in the documentation output.

  1. What did you expect to see?

Both examples in the code sample above should have worked - the return order of the imported type seems to be the only difference; I'm able to generate documentation for the function if the first return value type is not from the unqualified imported package.

  1. What did you see instead?

Only if a native type is returned first, or if the imported type has a qualifier, will the function appear correctly in the godoc output.

@mikeatlas

This comment has been minimized.

Copy link
Author

commented Apr 6, 2016

Would a test project here on GitHub demonstrating the bug be useful?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Apr 7, 2016

Maybe this is just punishment for using import .? :-)

@bradfitz

This comment has been minimized.

Copy link
Member

commented Apr 7, 2016

@bradfitz bradfitz added this to the Unplanned milestone Apr 7, 2016

@bradfitz bradfitz changed the title GoDoc - first return value with an unqualified imported type not showing up in documentation output cmd/godoc: first return value with an unqualified imported type not showing up in documentation output Apr 7, 2016

@mikeatlas

This comment has been minimized.

Copy link
Author

commented Apr 7, 2016

@bradfitz You know someone's eventually going to shoot themselves in the foot if you give out guns :) Thanks for triaging this.

@agnivade agnivade changed the title cmd/godoc: first return value with an unqualified imported type not showing up in documentation output x/tools/cmd/godoc: first return value with an unqualified imported type not showing up in documentation output Apr 25, 2018

@agnivade

This comment has been minimized.

Copy link
Member

commented Apr 25, 2018

@mikeatlas - Yes, it would be great if you can setup a test repo on github.

@agnivade

This comment has been minimized.

Copy link
Member

commented Apr 25, 2018

I am unable to repro this. Can you try with latest go 1.10.1 and godoc tip ?

@mikeatlas

This comment has been minimized.

Copy link
Author

commented Apr 25, 2018

If you can't repro it from the steps above, and no other reports, it is likely resolved!

@mikeatlas mikeatlas closed this Apr 25, 2018

@golang golang locked and limited conversation to collaborators Apr 25, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.