Skip to content

Instantly share code, notes, and snippets.

@erickhun
Created November 19, 2014 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erickhun/4e7a362b94bf5394531b to your computer and use it in GitHub Desktop.
Save erickhun/4e7a362b94bf5394531b to your computer and use it in GitHub Desktop.
Go Tour Excercice : Picture with Slices
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
picture := make([][]uint8, dy)
for y := range picture {
picture[y] = make([]uint8, dx) // Allocate 2nd slice dimensions
for x := range picture[y] {
picture[y][x] = uint8(x*y)
}
}
return picture
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment