golang初学之goroutine---web爬虫

摘要: go tour 练习 https://tour.go-zh.org/concurrency/10 阅读全文
posted @ 2016-05-17 16:50 白鹤亮翅 阅读(1033) 评论(0) 推荐(0) 编辑

golang初学之slice

摘要: golang tour 练习:https://tour.go-zh.org/moretypes/15 阅读全文
posted @ 2016-05-16 11:17 白鹤亮翅 阅读(178) 评论(0) 推荐(0) 编辑

golang初学之接口---image

摘要: 来自golang tour 练习 https://tour.go-zh.org/methods/16 阅读全文
posted @ 2016-05-16 08:11 白鹤亮翅 阅读(1155) 评论(0) 推荐(0) 编辑

golang初学之接口---rot13Reader

摘要: package main import ( "io" "os" "strings" ) type rot13Reader struct { r io.Reader } func (reader rot13Reader) Read(b []byte) (int, error) { n, err := reader.r.Read(b) for i:=0; i= 'A' && b[i]... 阅读全文
posted @ 2016-05-15 19:25 白鹤亮翅 阅读(285) 评论(0) 推荐(0) 编辑

golang初学之接口实现

摘要: package main import ( "fmt" ) type ErrNegativeSqrt float64// 实现Error接口,ErrNegativeSqrt 可以作为一个error来用 func (e ErrNegativeSqrt) Error() string { return fmt.Sprintf("cannot Sqrt negative number: %v"... 阅读全文
posted @ 2016-05-15 15:42 白鹤亮翅 阅读(172) 评论(0) 推荐(0) 编辑

golang初学之map

摘要: package main import ( "strings" "fmt") // 返回各个单词数量统计的map func WordCount(s string) map[string]int { m := make(map[string] int) for _, word := range str 阅读全文
posted @ 2016-05-15 11:39 白鹤亮翅 阅读(154) 评论(0) 推荐(0) 编辑

golang初学之 斐波纳契闭包

摘要: package main import "fmt" // fibonacci 函数会返回一个返回 int 的函数。func fibonacci() func() int { a , b:= 0, 1 return func() int { defer func() { a, b = b, a+b } 阅读全文
posted @ 2016-05-14 19:38 白鹤亮翅 阅读(358) 评论(0) 推荐(0) 编辑