[go: up one dir, main page]

🚀 Get 25% off access to all my premium courses - use discount code FUNCMAIN at checkout - view the pricing page now!

Getting the Size of an Array or Slice in Go Image Getting the Size of an Array or Slice in Go

In this code snippet, we are going to look at how you can retrieve the length of a type in Go using the len function.

In this example, we define an a slice of type string which contains a number of famous scientists. Below this instantiation, we then call len(scientists) to retrieve the length of this slice which is then printed out for us.

Further Reading:

If you enjoyed this code snippet, you may appreciate some of the other content on the site: