package main
import (
"fmt"
)
type test interface {
Error1() string
}
func New(name string) test {
return &student{name}
}
type student struct {
name string
}
func (s *student) Error1() string {
fmt.Println("Error1Error") // 21
return s.name
}
func main() {
s := New("mike")
fmt.Println("s = ", s)
// fmt.Println("s = ", s.Error1()) // Error
}
my test found that line 21 will print only if you change two places of Error1 in the code to the word Error, and any other words need to be manually called to the implemented method. Why? how does go do it