Discovergo podcast()003: Pointers or !Pointers, stack, and heap
003: Pointers or !Pointers, stack, and heap

003: Pointers or !Pointers, stack, and heap

Update: 2022-02-03
Share

Description

We go over what are pointers and when to use or not use them. For instance, this is probably not a good use for pointers.

func main() {
  var i int = 10
  abc(&i)
}

func abc(i *int) {
  *i = 15
}

In my opinion any dereferencing is probably bad. Better way:

func main() {
  var i int = 10
  i = abc(i)
}

func abc(i int) int {
  return 15
}

I also try to give some basics info regarding the stack and heap and why pointers might not be seen as an optimization.

I have a course on building SaaS in Go.

Follow me on Twitter.

Comments 
00:00
00:00
x

0.5x

0.8x

1.0x

1.25x

1.5x

2.0x

3.0x

Sleep Timer

Off

End of Episode

5 Minutes

10 Minutes

15 Minutes

30 Minutes

45 Minutes

60 Minutes

120 Minutes

003: Pointers or !Pointers, stack, and heap

003: Pointers or !Pointers, stack, and heap

Dominic St-Pierre