package main
import ( "fmt" )
type I interface { say() }
type S struct { name string }
func (s S) say() { fmt.Println(s.name) }
func main() { var s = S{"Jay"} fmt.Println(s)
var i1 I = s
i1.say()
i2 := []I{s} // 这里可以
i2[0].say()
i3 := I{s} //这里报错 invalid type for composite literal: I
i3.say()
} 请教一下,这段代码不理解为什么切片接口类型就能赋值,而接口类型就不可以