摘要:
1 package main 2 3 import "fmt" 4 5 func fibon(c,quit chan int) { 6 x,y := 1,1 7 for { 8 select { 9 case c <- x: //给主线程写数据10 x,y = y, x+y11 case <- quit: //给主线程写数据12 fmt.Println("quit")13 return14 }15 }16 }17 18 func main() {19 c := make(chan ...
阅读全文
posted @ 2013-09-02 20:34
笔记吧... 可能只有自己看得懂
阅读(1592)
推荐(0)
编辑
摘要:
1 package main 2 3 import( 4 "fmt" 5 "reflect" 6 ) 7 8 func main(){ 9 // iterate through the attributes of a Data Model instance10 for name, mtype := range attributes(&Dish{}) {11 fmt.Printf("Name: %s, Type %s\n", name, mtype.Name())12 }13 }14 15 // Data Model16 typ
阅读全文
posted @ 2013-09-02 17:35
笔记吧... 可能只有自己看得懂
阅读(917)
推荐(0)
编辑
摘要:
继承 1 package main 2 3 import "fmt" 4 5 type Skills []string 6 7 type person struct { 8 name string 9 age int10 weight int11 }12 13 type Student struct {14 person //继承15 Skills16 int17 spe string18 }19 20 func init() {21 22 }23 24 func main() {25 xuxu := Student{person{"xuxu",...
阅读全文
posted @ 2013-09-02 15:09
笔记吧... 可能只有自己看得懂
阅读(6052)
推荐(0)
编辑
摘要:
1 package main 2 3 import . "fmt" //notice 1 4 5 type testInt func(uint32) bool 6 7 func isOdd(integer uint32) bool { 8 if integer%2 == 0 { 9 return false10 }11 return true12 }13 14 func isEven(integer uint32) bool {15 if integer%2 == 0 {16 return true17 }18 return false19 }...
阅读全文
posted @ 2013-09-02 13:33
笔记吧... 可能只有自己看得懂
阅读(1065)
推荐(0)
编辑