2d slice in golang

// Allocate the top-level slice.
slice2D := make([][]uint8, rowSize) // One row per unit of y.
// Loop over the rows, allocating the slice for each row.
for i := range slice2D {
	slice2D[i] = make([]uint8, columnSize)
}
/**
## Slice in golang:
	- Because slices are variable-length, it is possible to have 
      each inner slice be a different length.
	- There are two ways to achieve this. 
		a. One is to allocate each slice independently; 
		b. the other is to allocate a single array and point 
           the individual slices into it.
*/

Are there any code examples left?
New code examples in category Go
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source