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

import/path: core #67494

Closed
lingdor opened this issue May 18, 2024 · 2 comments
Closed

import/path: core #67494

lingdor opened this issue May 18, 2024 · 2 comments

Comments

@lingdor
Copy link

lingdor commented May 18, 2024

Go version

go1.22.1 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/zhangxiaoxu/Library/Caches/go-build'
GOENV='/Users/zhangxiaoxu/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/zhangxiaoxu/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/zhangxiaoxu/go'
GOPRIVATE=''
GOPROXY='https://goproxy.io,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/85/455rptmx1d1g7s_qhnhnc9x00000gn/T/go-build3269171821=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

type tt struct {
}

func TestNIL(t *testing.T) {

	var a any
	var er *tt = nil
	a = er
	if a == nil {
		fmt.Println("expected")
	} else {
		t.Errorf("didn't expected: %+v", a)
	}
}

What did you see happen?

xiaoke_test.go:38: didn't expected: <nil>

--- FAIL: TestNIL (0.00s)
FAIL

What did you expect to see?

output:expected

@qiulaidongfeng
Copy link
Member

This is correct result.
Resaon see https://go.dev/doc/faq#nil_error

@mainjzb
Copy link

mainjzb commented May 18, 2024

It's right. a real type is * * tt .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants