golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.53k stars 521 forks source link

tour: Add warning that including fmt package makes the pic not show properly #1572

Open diegomezcota opened 6 months ago

diegomezcota commented 6 months ago

Context: https://go.dev/tour/moretypes/18

I was debugging and added "fmt" package just to add some prints for the values in the matrix and seeing if I was initializing it correctly. When you have the package imported, the pic is not displayed properly. I think adding a note would be great.

`package main

import ( "golang.org/x/tour/pic" "fmt" )

func Pic(dx, dy int) [][]uint8 { mat := make([][]uint8, dy) fmt.Println(mat) for i := range mat { mat[i] = make([]uint8, dx) }

for i := range mat {
    for j := range mat[i] {
        mat[i][j] = uint8(i^j)
    }
}
return mat

}

func main() { pic.Show(Pic) } `

image