Welcome To Golang By Example

Menu
  • Home
  • Blog
Menu

Pointer Arithmetic in Go (Golang)

Posted on October 11, 2023October 11, 2023 by admin

Table of Contents

  • Overview
  • Program

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)
  • go
  • golang
  • Popular Articles

    Golang Comprehensive Tutorial Series

    All Design Patterns in Go (Golang)

    Slice in golang

    Variables in Go (Golang) – Complete Guide

    OOP: Inheritance in GOLANG complete guide

    Using Context Package in GO (Golang) – Complete Guide

    All data types in Golang with examples

    Understanding time and date in Go (Golang) – Complete Guide

    ©2023 Welcome To Golang By Example | Design: Web XP