modified: eBook/18.1.md

modified:   eBook/18.10.md
	modified:   eBook/18.11.md
	modified:   eBook/18.2.md
	modified:   eBook/18.3.md
	modified:   eBook/18.4.md
	modified:   eBook/18.5.md
	modified:   eBook/18.6.md
	modified:   eBook/18.7.md
	modified:   eBook/18.8.md
	modified:   eBook/18.9.md
This commit is contained in:
songleo
2016-01-03 21:47:46 +08:00
parent 706c594a7e
commit 8fdcfd3776
11 changed files with 33 additions and 35 deletions

View File

@@ -34,9 +34,7 @@ for ix, ch := range str {
最快速:
`utf8.RuneCountInString(str)`
`len([]int(str)) //TBD`
`utf8.RuneCountInString(str)`
5如何连接字符串
@@ -55,7 +53,7 @@ for ix, ch := range str {
6如何解析命令行参数使用`os`或者`flag`包
(参考[例12.4](examples/chapter_12/fileinput.go)
(参考[例12.4](examples/chapter_12/fileinput.go)
## 链接

View File

@@ -1,6 +1,6 @@
# 18.10 其他
如何在程序出错时停止
如何在程序出错时终止程序
```go
if err != nil {
@@ -19,5 +19,5 @@ panic(“ERROR occurred: “ + err.Error())
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[网络和网页应用](18.9.md)
- 下一节:[出于性能考虑的最佳实践和建议](18.11.md)

View File

@@ -6,11 +6,11 @@
3尽可能的使用切片代替数组
4尽可能的使用数组和切片代替映射详见 参考文献15
4尽可能的使用数组和切片代替映射详见参考文献15
5如果只想获取切片中某项值不需要值的索引尽可能的使用`for range`去遍历切片,这比必须去查询切片中的每个元素要快一些;
6当数组元素是稀疏的例如有很多0值或者空值),使用映射会降低内存消耗;
6当数组元素是稀疏的例如有很多`0`值或者空值),使用映射会降低内存消耗;
7初始化映射时指定其容量
@@ -20,7 +20,7 @@
10尽可能在需要分配大量内存时使用缓存
11使用缓存模板参考15.7小节)。
11使用缓存模板参考[章节15.7](15.7.md))。
## 链接

View File

@@ -44,5 +44,5 @@ Found: for row := range arr2Dim {
## 链接
- [目录](directory.md)
- 上一[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一[字符串](18.1.md)
- 下一节:[映射](18.3.md)

View File

@@ -2,7 +2,7 @@
创建: `map1 := make(map[keytype]valuetype)`
初始化: `map1 := map[string]int{"one": 1, "two": 2}`
初始化 `map1 := map[string]int{"one": 1, "two": 2}`
1如何使用`for`或者`for-range`遍历一个映射:
@@ -25,5 +25,5 @@ for key, value := range map1 {
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[数组和切片](18.2.md)
- 下一节:[结构体](18.4.md)

View File

@@ -16,7 +16,7 @@ ms := &struct1{10, 15.5, "Chris"}
```
当结构体的命名以大写字母开头时,该结构体在包外可见。
通常情况下为每个结构体定义一个构建函数并推荐使用构建函数初始化结构体参考例10.2
通常情况下,为每个结构体定义一个构建函数,并推荐使用构建函数初始化结构体(参考[例10.2](examples/chapter_10/person.go)
```go
ms := Newstruct1{10, 15.5, "Chris"}
@@ -28,5 +28,5 @@ func Newstruct1(n int, f float32, name string) *struct1 {
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[映射](18.3.md)
- 下一节:[接口](18.5.md)

View File

@@ -34,5 +34,5 @@ func classifier(items ...interface{}) {
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[结构体](18.4.md)
- 下一节:[函数](18.6.md)

View File

@@ -1,6 +1,6 @@
# 18.6 函数
如何使用内建函数`recover`停止`panic`过程(参考13.3小节
如何使用内建函数`recover`停止`panic`过程(参考[章节13.3](13.3.md)
```go
func protect(g func()) {
@@ -19,5 +19,5 @@ func protect(g func()) {
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[接口](18.5.md)
- 下一节:[文件](18.7.md)

View File

@@ -48,5 +48,5 @@ func cat(f *file.File) {
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[函数](18.6.md)
- 下一节:[协程goroutine与通道channel](18.8.md)

View File

@@ -69,9 +69,9 @@ func pump() chan int {
5通道迭代器模板
6如何限制并发处理请求的数量参考14.11小节
6如何限制并发处理请求的数量参考[章节14.11](14.11.md)
7如何在多核CPU上实现并行计算参考14.13小节
7如何在多核CPU上实现并行计算参考[章节14.13](14.13.md)
8如何停止一个协程`runtime.Goexit()`
@@ -103,14 +103,14 @@ func Worker(in, out chan *Task) {
}
```
11如何在同步调用运行时间过长时将之丢弃参考14.5小节 第二个变体
11如何在同步调用运行时间过长时将之丢弃参考[章节14.5](14.5.md) 第二个变体
12如何在通道中使用计时器和定时器参考14.5小节
12如何在通道中使用计时器和定时器参考[章节14.5](14.5.md)
13典型的服务器后端模型参考14.4小节
13典型的服务器后端模型参考[章节14.4](14.4.md)
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[文件](18.7.md)
- 下一节:[网络和网页应用](18.9.md)

View File

@@ -12,10 +12,10 @@ var strTempl = template.Must(template.New(“TName”).Parse(strTemplateHTML))
`{{html .}}` 或者通过一个字段 `FieldName {{ .FieldName |html }}`
使用缓存模板(参考15.7小节
使用缓存模板(参考[章节15.7](15.7.md)
## 链接
- [目录](directory.md)
- 上一章:[运算符模板和接口](17.4.md)
- 下一节:[字符串](18.1.md)
- 上一章:[协程goroutine与通道channel](18.8.md)
- 下一节:[其他](18.10.md)