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

errors: examples need improvement #31716

Open
FiloSottile opened this issue Apr 27, 2019 · 2 comments

Comments

Projects
None yet
4 participants
@FiloSottile
Copy link
Member

commented Apr 27, 2019

There is a total of 4 examples in the package. Two are for New, one doesn't use the package at all, and one incorrectly uses As by dropping the error on the floor if it's not a os.PathError.

	_, err := os.Open("non-existing")
	if err != nil {
		var pathError *os.PathError
		if errors.As(err, &pathError) {
			fmt.Println("Failed at path:", pathError.Path)
		}
	}

@FiloSottile FiloSottile added this to the Go1.13 milestone Apr 27, 2019

@corona10

This comment has been minimized.

Copy link
Contributor

commented Apr 30, 2019

@FiloSottile Can I take a look at this issue?

@gopherbot

This comment has been minimized.

Copy link

commented May 4, 2019

Change https://golang.org/cl/175257 mentions this issue: errors: Add errors.Is examples

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