摘要: 1、代码2、运行 1 package main 2 3 import "fmt" 4 5 func testValue(){ 6 fmt.Println("for value") 7 var a = [3]int {1, 2, 3} 8 var b = a 9 ... 阅读全文
posted @ 2015-07-06 21:31 fengbohello 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 1、代码2、运行1、代码 1 package main 2 3 import "fmt" 4 5 type Base struct { 6 Name string 7 } 8 9 func (base * Base) Foo() {10 fmt.Println("Base Fo... 阅读全文
posted @ 2015-07-06 21:27 fengbohello 阅读(675) 评论(0) 推荐(0) 编辑
摘要: 1、代码2、运行1、代码 1 package main 2 3 import "fmt" 4 5 type Rect struct { 6 x, y float64 7 width, height float64 8 } 9 10 func (r * Rect) Area() f... 阅读全文
posted @ 2015-07-06 21:25 fengbohello 阅读(589) 评论(0) 推荐(0) 编辑
摘要: 1、代码2、运行1、代码 1 package main 2 3 import "fmt" 4 5 type Integer int 6 //给in类型添加 Less 方法,int原来的方法被Integer继承 7 func (a Integer) Less (b Integer) bool {... 阅读全文
posted @ 2015-07-06 21:20 fengbohello 阅读(1357) 评论(0) 推荐(0) 编辑