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: example for errors.As prints full source code of errors/example_test.go #39006

Closed
masiulaniec opened this issue May 11, 2020 · 2 comments
Closed
Labels
Milestone

Comments

@masiulaniec
Copy link

@masiulaniec masiulaniec commented May 11, 2020

When expanding the example https://pkg.go.dev/errors?tab=doc#example-As I see the text:

package errors_test

import (
	"errors"
	"fmt"
	"os"
	"reflect"
	"testing"
)

func TestIs(t *testing.T) {
	err1 := errors.New("1")
	erra := wrapped{"wrap 2", err1}
	errb := wrapped{"wrap 3", erra}
...

instead of the expected:

if _, err := os.Open("non-existing"); err != nil {
	var pathError *os.PathError
	if errors.As(err, &pathError) {
		fmt.Println("Failed at path:", pathError.Path)
	} else {
		fmt.Println(err)
	}
}
@gopherbot gopherbot added this to the Unreleased milestone May 11, 2020
@gopherbot gopherbot added the pkgsite label May 11, 2020
@D1CED
Copy link

@D1CED D1CED commented May 11, 2020

It's likely a duplicate of #38409.
Backport is on the way.

@julieqiu julieqiu added the NeedsFix label May 14, 2020
@julieqiu julieqiu changed the title go.dev: example for errors.As prints full source code of errors/example_test.go x/pkgsite: example for errors.As prints full source code of errors/example_test.go Jun 15, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 20, 2020

Change https://golang.org/cl/239180 mentions this issue: internal/fetch/internal/doc: fix detection of whole file examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants