Sling Academy
Home/Golang/Working with Slices in Go

Working with Slices in Go

In Go, a slice is a flexible, dynamic data structure that provides a more powerful and convenient abstraction over arrays. Unlike arrays, which have a fixed size, slices are dynamic and can grow or shrink as needed.

This series of tutorials will help you understand slices deeply, through practical examples as well as clear explanations.

1 Array vs Slice in Go: What is difference?

2 Multiple ways to create a slice in Go

3 How to get the length of a slice in Go

4 Go: Workarounds to Hold Multiple Data Types in a Slice

5 How to append/ prepend elements to a slice in Go

6 How to Access Slice Elements by Index in Go

7 Go Slice: Modifying Elements by Index

8 Go Slice: Finding Index of an Element (Manual Search)

9 How to Insert a New Element to a Slice

10 Go: Inserting an element into a slice at a specific index

11 Go: How to remove a slice element by its index

12 Ways to iterate through a slice in Go

13 How to remove duplicates from a slice in Go

14 Sorting a slice of integers in Go

15 Sorting a slice of floats in Go

16 Sorting a slice of strings in Go

17 How to sort custom types in a slice in Go (advanced)

18 Filtering numbers in a slice in Go

19 How to filter strings in a slice in Go

20 Filtering composite types in a slice in Go

21 Calculate the sum and average of a numeric slice in Go

22 How to check if a slice is empty in Go

23 How to clear all slice elements in Go

24 How to Calculating Variance and Standard Deviation in Go

25 Capacity and Length: Managing Slice Growth in Go

26 Creating Slices from Arrays in Go

27 Copying Slices in Go: Efficient Techniques

28 Passing a Slice to a Function as an Argument in Go

29 Using Slices as Function Return Values in Go

30 Nested Slices: Working with Multi-Dimensional Data in Go

31 Slices of Structs: Storing Complex Data in Go

32 Understanding Slice References and Data Mutations in Go

33 Avoiding Common Mistakes with Slices in Go

34 Optimizing Performance When Using Slices in Go

35 Working with Empty and Nil Slices in Go

36 How to Clear a Slice in Go: Techniques and Best Practices

37 Using Slices with Pointers in Go: Advanced Use Cases

38 Slices as Queues and Stacks in Go: Implementation Examples

39 Exploring Slice Capacity Growth in Go

40 Memory Management for Slices in Go

41 Practical Use Cases for Slices in Go Applications

42 Debugging Issues with Slices in Go

43 Using Reflect to Inspect Slices Dynamically in Go

44 Concurrency and Slices: Managing Data Safely in Go

45 Converting Slices to Arrays in Go

46 Slicing Strings: Using Slices for Text Manipulation in Go

47 Advanced Techniques for Modifying Slices in Go

48 Working with Nested and Jagged Slices in Go

49 Building a Dynamic Data Structure with Slices in Go

50 Comparing Slices: Equality and Identity in Go

51 Using Custom Types with Slices in Go

52 Slices in JSON Encoding and Decoding in Go

53 Handling Errors and Edge Cases with Slices in Go

54 Working with Large Data Sets Using Slices in Go

55 How to find common elements of 2 slices in Go