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
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite
Milestone

Comments

@masiulaniec
Copy link

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
@D1CED
Copy link

D1CED commented May 11, 2020

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

@julieqiu julieqiu added the NeedsFix The path to resolution is known, but the work has not been done. 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

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

@golang golang locked and limited conversation to collaborators Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite
Projects
None yet
Development

No branches or pull requests

4 participants