work
package main
import (
"fmt"
)
type Test interface{
Run()
// Debug()
}
type My struct{
body string
}
func (m My)Run(){
fmt.Println(m.body)
}
func main() {
my := &My{body: "DOOOOOOOO"}
fmt.Println("Hello, playground")
testRun(my)
}
func testRun(t Test){
t.Run()
}
↓
Hello, playground
DOOOOOOOO
Error
package main
import (
"fmt"
)
type Test interface{
Run()
// Debug()
}
type My struct{
body string
}
func (m My)Run(){
fmt.Println(m.body)
}
func main() {
my := &My{body: "DOOOOOOOO"}
fmt.Println("Hello, playground")
testRun(my)
}
func testRun(t Test){
t.Run()
}
↓
./prog.go:23:9: cannot use my (type *My) as type Test in argument to testRun:
*My does not implement Test (missing Debug method)