[root@sltvb7v2wy3 jia_point]# cat execrise_slices.go
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
var pic [][]uint8;
for i := 0; i < dy; i++ {
var one_line []uint8
for j := 0; j < dx; j++ {
one_line = append(one_line, (uint8)(i & j))
}
pic = append(pic, one_line)
}
return pic
}
func main() {
pic.Show(Pic)
}
[root@sltvb7v2wy3 jia_point]# go mod init main/execrise_slices.go
go: creating new go.mod: module main/execrise_slices.go
go: to add module requirements and sums:
go mod tidy
[root@sltvb7v2wy3 jia_point]# ls
append.go execrise_slices.go nil_slice.go range.go slice_literals.go slices_pointers.go struts_fields.go
append_slice.go go.mod points.go slice_bounds.go slices.go struct_literals.go struts.go
array.go making_slices.go range_continued.go slice_len_cap.go slices_of_slice.go struct_pointers.go
[root@sltvb7v2wy3 jia_point]# go mod tidy
go: finding module for package golang.org/x/tour/pic
go: found golang.org/x/tour/pic in golang.org/x/tour v0.1.0
[root@sltvb7v2wy3 jia_point]# gor execrise_slices.go
IMAGE:iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAEgklEQVR42uzdUYrjOhSE4XLwQx6zBC3FS8vK4yFkAh06hrZptSPrE5efojgIM3A5HZePNCZzLKvXdUoyDEHsk8OjA5zu/yPkdgtNd6V1AOyaY5J5vv+XZBxf/jzi8w/v6wCoA8z//x6i6d60DoA6wPNvo6/rfF58dape/WHqdQDUAZ5/Dz3+1/n+dxKff1RfB0AdwPtgvhwAUQ5A03IARDnA0rpcVn9ybX/7f+z+OgDqAO/ejy5p9eqPVK8DoA7gfTBfDoAoB6BpOQCiHMD34urNAyCaB+DzzQMgygH4fDkAohyApuUAiP3NA6xdpaT28vyef/PSAVAHWPP99Fptf/t/8v46AOoA3gfz5QCIcgCalgMgygF8L67ePACieQA+3zwAohyAz5cDIMoBaFoOgBj3A/zy9+L2t/9f7q8DoA7g/Hj17gdAlAN4T8yXAyDKAWhaDoBoHsD35erNAyCaB+DzzQMgygH4fDkAohyAp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