This page looks best with JavaScript enabled

Go - Slice basics

 ·  ☕ 1 min read  ·  ✍️ Neeraj Sidhaye · 👀... views

Small post to explain go slice basics, specially around slice length and capacity.
How an underlyig array is created in memory when we

  • create a new slice
  • create a new slice from an existing slice
  • appending elments to a slice
  • what happnes when underlaying array is full when we keep appending elements to slice.

Refer to code

go slice basic example here

go slice visuals

go-slice

Share on

{Neeraj:Sidhaye}
WRITTEN BY
Neeraj Sidhaye
I Aspire to Inspire before I Expire!