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

posts/go/value-quote/ #169

Open
utterances-bot opened this issue Nov 1, 2022 · 4 comments
Open

posts/go/value-quote/ #169

utterances-bot opened this issue Nov 1, 2022 · 4 comments

Comments

@utterances-bot
Copy link

群里又吵起来了,Go 是传值还是传引用?

https://eddycjy.com/posts/go/value-quote/

Copy link

koushr commented Nov 1, 2022

func main() {
s := "脑子进煎鱼了"
fmt.Printf("main 内存地址:%p\n", &s)
hello(&s)
}

func hello(s *string) {
fmt.Printf("hello 内存地址:%p\n", &s)
}

1 similar comment
Copy link

koushr commented Nov 1, 2022

func main() {
s := "脑子进煎鱼了"
fmt.Printf("main 内存地址:%p\n", &s)
hello(&s)
}

func hello(s *string) {
fmt.Printf("hello 内存地址:%p\n", &s)
}

Copy link

koushr commented Nov 1, 2022

func main() {
s := "脑子进煎鱼了"
fmt.Printf("main 内存地址:%p\n", &s)
hello(&s)
}

func hello(s *string) {
fmt.Printf("hello 内存地址:%p\n", &s)
}
hello里面不应该是这样打印吗? fmt.Printf("hello 内存地址:%p\n", s) 这样打印出来结果是一样的

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

3 participants