Welcome To Golang By Example

Pointer Arithmetic in Go (Golang)

Table of Contents

Overview

Pointer arithmetic is not possible in golang unlike C language. It raises compilation error.

Program

package main
func main() {
    a := 1
    b := &a
    b = b + 1
}

Output

Above program raises compilation error

invalid operation: b + 1 (mismatched types *int and int)