摘要: 很多面向对象语言都有借口的概念,Go语言的接口独特之处在于它是隐式实现的。 接口定义和实现 /* 定义接口 */ type interface_name interface { method_name1 [return_type] method_name2 [return_type] method_ 阅读全文
posted @ 2020-12-21 21:02 尹瑞星 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 函数 函数声明 go语言函数支持多返回值。 func name(parameter-list)(result-list){ body } 当函数存在返回列表的时候,必须显示以return结束。(除了break,抛异常等操作) func sub(x,y int) (z int){ z = x-y;re 阅读全文
posted @ 2020-12-21 14:54 尹瑞星 阅读(465) 评论(0) 推荐(0) 编辑