Create and Print Multi Dimensional Slice in Golang
This is a multidimensional in slice that stores inner in slices. So each element of the slice is another in slice. This is a short declaration of a multidimensional slice.
Example
package main
import "fmt"
func main() {
sales := [][]int{
{100, 200},
{300},
{400, 500},
}
for _, x := range sales {
for _, y := range x {
fmt.Println(y)
}
}
}
Output
100
200
300
400
500
Most Helpful This Week
How to create Map using the make function in Go?
Find capacity of Channel, Pointer and Slice
How to remove symbols from a string in Golang?
How to get struct variable information using reflect package?
Regular expression to validate the date format in "dd/mm/yyyy"
How to fix race condition using Atomic Functions in Golang?
How to Unmarshal nested JSON structure?
How to create a photo gallery in Go?
How to add Watermark or Merge two image?
How to Convert string to float type in Go?