DEV Community

Cover image for Golang perk series : *pointers in Go – basics #5
LG
LG

Posted on • Edited on

1 1

Golang perk series : *pointers in Go – basics #5

Pointers in Go := pass-by-reference :

Please refer to the sample by the name of pointers.go on REPLIT IDE

Before getting into pointers I want to examine this pseudo_code:

var pointer_variable *T = &another_variable // <= herein we defined a "pointer-to-memory" pair
/* 
such pair could either:
a) be referenced using ampersand (&), subsequently getting memory address
b) be DE-referenced using asterisk (*), subsequently getting UNDERLYING VALUE of memory address
*/
Enter fullscreen mode Exit fullscreen mode

JavaScript has some pass-by-reference -like behaviour with (outermost) object reference[s] but definitely none of native pointers specification [ – if you still fascinated by the idea of JS pointers, have a look at others/ifJS_pointers.go on REPLIT IDE ; also – pass by reference in JavaScript, stack overflow discussion]

We will see advanced pointers utilisation in structs & relevant fields, stay tuned for updates !


Articles :

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay