go-gin-api 代码写法

package main
import "fmt"
var _ Study = (*study)(nil)
type study struct {
Name string
}
type Study interface {
Listen(message string) string
}
func main() {
fmt.Println("hello world")
./main.go:5:5: cannot use (*study)(nil) (type *study) as type Study in assignment:
*study does not implement Study (missing Listen method)
var _ Study = (*study)(nil)
package study
type Study interface {
Listen(message string) string
i()
}func Speak(s Study) string {
return s.Listen("abc")
type stu struct {
Name string
}
func (s *stu) Listen(message string) string {
return s.Name + " 听 " + message
}
func (s *stu) i() {}
func main() {
message := study.Speak(new(stu))
fmt.Println(message)./main.go:19:28: cannot use new(stu) (type *stu) as type study.Study in argument to study.Speak:
*stu does not implement study.Study (missing study.i method)
have i()
want study.i()

go-gin-api 代码写法

上一篇:微信小程序登录


下一篇:微信授权登入