編碼package mainimport "fmt"type unimplementedGreeterServer struct {}func (unimplementedGreeterServer) SayHello() string { return "hello"}func main() { s := &unimplementedGreeterServer{} ret := s.SayHello() fmt.Println(ret)}結(jié)果hello問題:為什么 SayHello 方法沒有 unimplementedGreeterServer 點(diǎn)或 unimplementedGreeterServer 接收器可以運(yùn)行我認(rèn)為權(quán)利將是func (s unimplementedGreeterServer) SayHello2() string { return "hello"}func (s *unimplementedGreeterServer) SayHello3() string { return "hello"}不是func (unimplementedGreeterServer) SayHello() string { return "hello"}
為什么 Go 接受這種方法定義語法?
幕布斯7119047
2022-10-17 10:02:21