Closed
Description
Go version
go version go1.23.0 darwin/arm64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
What did you do?
package main
import "fmt"
type CustomError struct {
Message string
}
func (e *CustomError) Error() string {
return e.Message
}
func main() {
fmt.Println(parent() == nil)
}
func parent() error {
return child()
}
func child() *CustomError {
return nil
}
https://go.dev/play/p/AYl4dQpc2pm
What did you see happen?
I expect the result of the parent()
function to equal nil
.
What did you expect to see?
I expect the result of the parent()
function to equal nil
.
If the child()
function' return type is set to error
, it will work fine.
Metadata
Metadata
Assignees
Labels
No labels