golang/go

x/pkgsite/cmd/pkgsite: Examples not executable if pkg.name != basename(pkg.path)

Open

#12.794 geöffnet am 30. Sept. 2015

Auf GitHub ansehen
 (9 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Go (19.008 Forks)batch import
Toolshelp wantedpkgsite

Repository-Metriken

Stars
 (133.883 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Update: see https://github.com/golang/go/issues/12794#issuecomment-3667366323

% export GOPATH=$(pwd) % cat src/foo1/foo.go package foo

func Foo() { }

% cat src/foo1/foo_test.go package foo_test

import "foo1" // defines foo

func ExampleFoo() { foo.Foo() }

% godoc -play -http :9999 & % open http://localhost:9999/pkg/foo1/#pkg-examples

The example is shown but not executable (grey not yellow); renaming foo1 to foo makes it executable, as does using an explicit (redundant) renaming import: import foo "foo1"

Seems like some code in godoc is assuming pkg.name == basename(pkg.path) instead of finding the actual package name.

Contributor Guide