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/net cannot use errors.Is on net.DNSError #40179

Closed
georgettica opened this issue Jul 12, 2020 · 2 comments
Closed

x/net cannot use errors.Is on net.DNSError #40179

georgettica opened this issue Jul 12, 2020 · 2 comments

Comments

@georgettica
Copy link

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

$ go version
go version go1.14.4 darwin/amd64

Does this issue reproduce with the latest release?

this is the latest release on brew, so I would say yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/$USER/.gvm/pkgsets/system/global/bin/"
GOCACHE="/Users/$USER/Library/Caches/go-build"
GOENV="/Users/$USER/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/$USER/.gvm/pkgsets/system/global"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/$TEMP_FOLDER=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

when I used a a http.Get(url) to a location that is not public accessible, I get a net.DNSError. I am trying to catch that error, and tried to use errors.Is but this seemed to fail.
My current workarounds:

  • remove test url.Error instead (not ideal)
  • unwrap to the level I need and test for net.DNSError

you can see the code here..
https://play.golang.org/p/hl9bbhQnL2i
if you comment section 3 you will see section 4 succeed aswell.

What did you expect to see?

I expect errors.Is to work for me or at lest to find a documentation for how to make it work

What did you see instead?

I see I need to use the unwrapping and testing myself

@gopherbot gopherbot added this to the Unreleased milestone Jul 12, 2020
@seankhliao
Copy link
Member

seankhliao commented Jul 12, 2020

use errors.As https://blog.golang.org/go1.13-errors#TOC_3.2.

see https://github.com/golang/go/wiki/Questions for the appropriate place to ask questions

@mdlayher
Copy link
Member

See above, closing.

@golang golang locked and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants