How Double Pointers Work in Go (**T)

Go uses **T syntax for double pointers to allow functions to modify the address stored in a pointer variable.

Go does not support double pointers like C; you must use a pointer to a pointer (**T) to modify a pointer variable passed to a function. Use **T as the parameter type and dereference twice to assign a new address to the original pointer.

func updatePtr(ptr **int) {
	*ptr = new(int)
	**ptr = 42
}

func main() {
	var p *int
	updatePtr(&p)
	fmt.Println(*p) // Output: 42
}