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/pkgsite: exported methods of generic type omitted #50412

Closed
muhlemmer opened this issue Jan 3, 2022 · 6 comments
Closed

x/pkgsite: exported methods of generic type omitted #50412

muhlemmer opened this issue Jan 3, 2022 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite release-blocker
Milestone

Comments

@muhlemmer
Copy link
Contributor

muhlemmer commented Jan 3, 2022

What version of Go are you using (go version)?

$ go version
go version go1.18beta1 linux/amd64

$ gotip version
go version devel go1.18-c8861432b8 Sun Jan 2 14:27:43 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Beta1 release of Go 1.18 and master through gotip with type parameter support.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vscode/.cache/go-build"
GOENV="/home/vscode/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18beta1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/workspaces/godoc_generics_issue/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1808945237=/tmp/go-build -gno-record-gcc-switches"
gotip env Output
$ gotip env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vscode/.cache/go-build"
GOENV="/home/vscode/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/vscode/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/vscode/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-c8861432b8 Sun Jan 2 14:27:43 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/workspaces/godoc_generics_issue/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build338508180=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Add a generic (struct) type with methods:

type MyType[T any] struct {
	i T
}

func (m *MyType[T]) Set(i T) {
	m.i = i
}

func (m *MyType[T]) Get() T {
	return m.i
}

Run go doc or gotip doc (same output).

What did you expect to see?

MyType, and its Get() and Set() methods printed.

What did you see instead?

Methods added to a generic (struct) type are not printed.

package godoc_generics_issue // import "github.com/muhlemmer/godoc_generics_issue"

type MyType[T any] struct{ ... }

Additional info:

  1. Running go doc -all does print the the methods, although they should also be printed without -all flag, as the methods are exported.
  2. Runing pkgsite, the package page (http://127.0.0.1:8080/github.com/muhlemmer/godoc_generics_issue) also omits the methods.
  3. Running godoc server, panics when visiting the the package page. I raised a seperate issue x/tools/godoc: panic with generic type with methods #50413, as I'm not sure if this is related or a different bug.
@ianlancetaylor ianlancetaylor changed the title go/doc: Exported methods of generic type omitted cmd/go: go doc: exported methods of generic type omitted Jan 3, 2022
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Jan 3, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.18 milestone Jan 3, 2022
@ianlancetaylor
Copy link
Contributor

CC @findleyr

@findleyr
Copy link
Contributor

findleyr commented Jan 3, 2022

Thanks for the report.

CC @jba. https://golang.org/cl/375095 may be indirectly related.

Commented on the godoc issue, which I think is unrelated.

@jba jba self-assigned this Jan 3, 2022
@jba
Copy link
Contributor

jba commented Jan 4, 2022

I can't reproduce this. go doc <pkgname> shows only the type, not the methods, but that has always been its behavior. go doc <pkgname>.<type> shows the methods.

I found the same behavior at tip (e39ab9b) with the declarations given above.

@muhlemmer
Copy link
Contributor Author

I can't reproduce this. go doc <pkgname> shows only the type, not the methods, but that has always been its behavior. go doc <pkgname>.<type> shows the methods.

I found the same behavior at tip (e39ab9b) with the declarations given above.

Ok, well my apologies then.

In fact, I found the godoc bug (panic) first and tried to find a common denominator. For instance, I found pkgsite omits the methods from from the page. A previous issue I reported on generics, there was a common bug. So I falsely assumed this to be a common bug with go doc as well.

I'll rephrase this issue to apply only to pkgsite:
image

Steps to reproduce:

  1. Same source as the original issue;
  2. Run pkgsite build against Go 1.18beta1, or master (gotip);
  3. Browse to the package page (http://127.0.0.1:8080/github.com/muhlemmer/godoc_generics_issue) in my case;
  4. Find the methods are missing;

@muhlemmer muhlemmer changed the title cmd/go: go doc: exported methods of generic type omitted x/pkgsite: exported methods of generic type omitted Jan 6, 2022
@jba
Copy link
Contributor

jba commented Jan 6, 2022

pkgsite doesn't support generics yet. It will soon, some time before the go 1.18 release.

@jba
Copy link
Contributor

jba commented Jan 11, 2022

Since this reduces to #48264, closing in favor of that.

@jba jba closed this as completed Jan 11, 2022
@rsc rsc unassigned jba Jun 22, 2022
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants