Estou apenas trabalhando no tour Go e estou confuso sobre ponteiros e interfaces. Por que esse código Go não é compilado?
package main
type Interface interface {}
type Struct struct {}
func main() {
var ps *Struct
var pi *Interface
pi = ps
_, _ = pi, ps
}
ou seja, se Structé um Interface, por que não *Structseria um *Interface?
A mensagem de erro que recebo é:
prog.go:10: cannot use ps (type *Struct) as type *Interface in assignment:
*Interface is pointer to interface, not interface
func main() { var ps *Struct = new(Struct) var pi *Interface var i Interface i = ps pi = &i fmt.Printf("%v, %v, %v\n", *ps, pi, &i) i = *ps fmt.Printf("%v, %v, %v\n", *ps, pi, i) _, _, _ = i, pi, ps }e fazer suas próprias conclussions
