Pointers in Golang

What’s a pointer ?

In Go , A pointer is a variable whose value is a memory address.

A pointer is defined using the ampersand operator.

Following a Pointer

In order to access ie following the pointer value , Go uses the asterisk operator.

Why is it needed ?

Pointers are very useful in Go because they allow the programmer to choose between passing a value and passing a reference

Key takeaways

  1. A pointer is a variable whose value is a memory address
  2. Pointers are defined using ampersand , address operator
  3. Pointers are followed using asterisk operator
  4. You can point at pointers
  5. Go does not support pointer arithmetic to prevent memory address manipulation
  6. Pointers are useful when choosing passing by value or by reference

https://github.com/ABISHEIKH/PointersInGolang.git

--

--

--

Golang Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Why Teams Adopting Kubernetes Fight over Capacity Management?

How to Hire a ColdFusion Software Development Company without Freaking Out (9 best practices)

Managing visibility in Flutter

Introduction to Linkerd

Some musings on how we write code

0-From ASP.NET to Flutter — The web coder path to Flutter

Coffee you will need

The Four Interfaces of SaaS product suites

Dear Go — Thank You For Teaching Me PHP Was A Waste of My Time

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abdi Ismail

Abdi Ismail

Golang Engineer

More from Medium

Learn Go: Concurrency

SOLID Principles of Object-Oriented Design in GoLang (Part-3)

Gorutin: go concurrency using generics

Get a file extension from a URL in Golang