I have a Go object whose address in memory I would like to keep constant. in C# one can pin an object’s location in memory. Is there a way to do this in Go?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An object on which you keep a reference won’t move. There is no handle or indirection, and the address you get is permanent.
From the documentation :
When you set a variable, you can read this address using the
&operator, and you can pass it.