Programming Languages
Go
Subjective
Oct 04, 2025
What are pointers in Go and how are they used?
Detailed Explanation
Pointers in Go:
• Store memory addresses of variables
• Use & to get address, * to dereference
• No pointer arithmetic (unlike C)
• Zero value is nil
• Useful for efficiency and modification
Example:
var x int = 42
var p *int = &x // p points to x
fmt.Println(*p) // prints 42
*p = 21 // changes x to 21
func modify(p *int) {
*p = 100
}
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts