Operator and syntax

Go address and dereference operators

& obtains a pointer to an addressable operand (with a composite literal exception). * accesses the referenced variable; dereferencing nil panics. The same symbols have separate bitwise or arithmetic meanings. Example output: '9'.

Formal Syntax & Structure

go syntaxgo
&x; *p

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  n := 2  p := &n  *p = 9  fmt.Println(n)}
Go Reference