DEV Community

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

Posted on • Edited on

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 :

Top comments (0)