GoLang — Optimisations

--

Go- Arrays:

  1. When iterating over an array it’s faster to pass a pointer to that array to the for loop. This prevents the loop from copying the whole array which is beneficial for both CPU and memory usage.
    Reference: https://medium.com/@haaawk/i-thought-i-understood-how-iteration-over-an-array-works-but-apparently-not-in-golang-441a7abd6540
  2. If we want to modify the array while we’re iterating over it, we need to either give a for loop a pointer to that array or use the array index operator directly.

--

--

Akhilesh Mahajan

Full-Stack Developer | Golang, Java, Rust, Node, React Developer | AWS☁️, Docker, Kubernetes | Passionate about distributed systems and cloud-native application