운동을 통해 wokring하고 있습니다 : 이미지는 https://tour.golang.org/methods/25이고 문제가 발생했습니다. 여기에 내 코드 ... 그것은 나에게 오류를 제공golang exercise : 방법에 이미지가 누락되었습니다.
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)
}
...
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)
는 그러나 image.NewRGBA
*NRGBA
을 반환하고는 참으로 At()
방법을 가지고있다. 또한 At()
메서드가 image.Image
인터페이스에서 필요로하는 마지막 메서드이기 때문에 다른 두 개의 필수 메서드를 찾는 것으로 가정합니다 ... At()
은 무엇입니까?
image.NRGBA : https://golang.org/pkg/image/#NRGBA
image.Image 인터페이스 : https://golang.org/pkg/image/#Image