Implementation of the exercise: Slices in “A Tour of Go”

Source: https://www.taste.com.au/recipes/old-fashioned-vanilla-slice/103b8a36-613f-40b3-9b7d-c162d238bee5

When you begin to learn the trending Go lang you may have encounter with the Slice exercise which will ask you to draw an image based on slices. Here is how I implemented it.

package main
import (
"golang.org/x/tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
pixel := make([][]uint8, dy)
data := make([]uint8, dx)
for i := range pixel {
for j := range data {
data[j] = uint8((i+j)/2)
}
pixel[i] = data
}
return pixel
}
func main() {
pic.Show(Pic)
}