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

Nil pointer to struct implementing error interface is nil, but error(x) == nil returns false #24947

Closed
wallnutkraken opened this issue Apr 19, 2018 · 2 comments

Comments

@wallnutkraken
Copy link

wallnutkraken commented Apr 19, 2018

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

go version go1.9.4 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/gnugat/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build810068483=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
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"

What did you do?

https://play.golang.org/p/x5Ix8wmC0Oj

What did you expect to see?

errImpl is nil
error(errImpl) is nil

What did you see instead?

errImpl is nil
ErrImpl value: <nil>
@wallnutkraken wallnutkraken changed the title Nil pointer to struct implementing error interface is nil, but x == nil returns false Nil pointer to struct implementing error interface is nil, but error(x) == nil returns false Apr 19, 2018
@go101
Copy link

go101 commented Apr 19, 2018

This is not a bug. Please read https://go101.org/article/unofficial-faq.html#nil-equality for explanations.

@ALTree
Copy link
Member

ALTree commented Apr 19, 2018

Also Why is my nil error value not equal to nil?

Closing this, since it's not a bug.

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