首页 > Windows开发 > 详细

go-gin-api 代码写法

时间:2021-09-07 05:37:00      阅读:27      评论:0      收藏:0      [点我收藏+]

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 代码写法

原文:https://www.cnblogs.com/ymcs/p/15232405.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!