-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
builtin: append will change addr of element in slice ? #71169
Comments
zhuliquan
changed the title
builtin: append will change addr of slice ?
builtin: append will change addr of element in slice ?
Jan 8, 2025
This is behaving as expected.
|
see #27821 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go version
go version go1.23.2 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I write a function to extract element from a slice, this function will return a element and a slice which contains other element.
What did you see happen?
I write below case to invoke
partSlice
func.the result is
I am confuse that
k
is 2, I expect it is 1. Andl
is replace to[2 2]
!According to addr of
s
andl
.append(l[idx], l[idx+1]...)
make 1th and 2nd elment have same addr?What did you expect to see?
expect got result is
1 [2]
The text was updated successfully, but these errors were encountered: