问题 I can't gracefully get pixels of an image as array in general case. f, err := os.Open(imgPath) check(err) defer f.Close() img, _, err := image.Decode(bufio.NewReader(f)) check(err) pixels, err := getPixels(img) check(err) // Logic with pixels. Now function getPixels looks like this: func getPixels(img image.Image) ([]uint8, error) { if i, ok := img.(*image.NRGBA); ok { return i.Pix, nil } else if i, ok := img.(*image.Alpha); ok { return i.Pix, nil } else if i, ok := img.(*image.Alpha16); ok {