Hacker News new | past | comments | ask | show | jobs | submit login

I think Go doesn't allow you to pass ownership of the pointer to another language, and you need to make sure the pointer is no longer used by the other language by the time Go cleans it up, but I think you can (for example) pass a Go pointer into C.

Yes, you can, but there are more constraints. E.g. you are also not permitted to pass a pointer to Go memory that contains Go pointers. There is a detailed description here:

https://golang.org/cmd/cgo/#hdr-Passing_pointers

Also, it used to be the case that cgo calls were relatively expensive (definitely not something you want to do in a hot loop). I am not sure if this is still true, but it was when I was using Go daily for projects.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: