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

用 Go struct 不能犯的一个低级错误! #156

Open
skarner2016 opened this issue Dec 20, 2021 · 0 comments
Open

用 Go struct 不能犯的一个低级错误! #156

skarner2016 opened this issue Dec 20, 2021 · 0 comments

Comments

@skarner2016
Copy link

func main() {
a := new(struct{})
b := new(struct{})
println(a, b, a == b)

c := new(struct{})
d := new(struct{})
fmt.Println(c, d)
println(c, d, c == d)

}

文章链接 https://juejin.cn/post/6974615908861870094
文中提到,因为 fmt.println 方法造成逃逸行为,导致第一个输入 false,第二个输出 true

可能是因为版本问题(我目前是1.17.1),两个都输出的 true ,附图
12

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

1 participant