既存のインターフェースを拡張することは可能ですか? 動作しない単純なコード スニペットがあります。
パッケージメイン
import (
"fmt"
"io"
)
type Aaa struct {}
// Implementing io.ReaderAt interface
func (a Aaa)ReadAt(p []byte, off int64) (n int, err error) {
return
}
// Extending it
func (a *Aaa) A() {
fmt.Println("A")
}
func main() {
list := [1]io.ReaderAt{Aaa{}} // Use Aaa object as io.ReaderAt type
list[0].A() //Trying to use an extended type. << Error occurred here
}
list[0].A undefined (タイプ io.ReaderAt にはフィールドまたはメソッド A がありません)
別のパッケージからのインターフェイスを実装できないことを伝える方法ですか?