I am wokring through the exercise:images at https://tour.golang.org/methods/25 and I have run into a problem. Here is my code...
package main
import (
"golang.org/x/tour/pic"
"image"
)
type Image struct{
image *image.RGBA
}
func main() {
rect := image.Rect(0,0,255,255)
myImage := image.NewRGBA(rect)
m := Image{myImage}
pic.ShowImage(m)
}
it gives me the error...
tmp/sandbox089594299/main.go:16: cannot use m (type Image) as type image.Image in argument to pic.ShowImage:
Image does not implement image.Image (missing At method)
But image.NewRGBA
returns a *NRGBA
and that does indeed have an At()
method. Also I assume since the At()
method is the last method required by the image.Image
interface then it is finding the other two required methods...so what is up with the At()
?
image.NRGBA: https://golang.org/pkg/image/#NRGBA
image.Image interface: https://golang.org/pkg/image/#Image