modified: eBook/18.1.md

modified:   eBook/18.10.md
	modified:   eBook/18.2.md
	modified:   eBook/18.3.md
	modified:   eBook/18.6.md
	modified:   eBook/18.8.md
	modified:   eBook/18.9.md
This commit is contained in:
songleo
2016-01-03 14:43:12 +08:00
parent 0aefb4a032
commit b3550e98e3
7 changed files with 19 additions and 14 deletions

View File

@@ -34,9 +34,7 @@ for ix, ch := range str {
最快速:
```go
utf8.RuneCountInString(str)
```
`utf8.RuneCountInString(str)`
`len([]int(str)) //TBD`
@@ -47,7 +45,7 @@ for ix, ch := range str {
`Strings.Join()`(参考[章节4.7](04.7.md)
`+=`
使用`+=`
```go
str1 := "Hello "

View File

@@ -1,6 +1,6 @@
# 18.10 其他
如何在程序出错时停止:
如何在程序出错时停止:
```go
if err != nil {
@@ -9,7 +9,7 @@ if err != nil {
}
```
或者:
或者:
```go
if err != nil {
panic(“ERROR occurred: “ + err.Error())

View File

@@ -1,15 +1,19 @@
# 18.2 数组和切片
创建: `arr1 := new([len]type)`
`slice1 := make([]type, len)`
初始化:`arr1 := [...]type{i1, i2, i3, i4, i5}`
`arrKeyValue := [len]type{i1: val1, i2: val2}`
`var slice1 []type = arr1[start:end]`
1如何截断数组或者切片的最后一个元素
`line = line[:len(line)-1]`
`line = line[:len(line)-1]`
2如何使用`for`或者`for-range`遍历一个数组(或者切片):

View File

@@ -1,6 +1,7 @@
# 18.3 映射
创建: `map1 := make(map[keytype]valuetype)`
初始化: `map1 := map[string]int{"one": 1, "two": 2}`
1如何使用`for`或者`for-range`遍历一个映射:

View File

@@ -1,6 +1,6 @@
# 18.6 函数
如何使用内建函数recover停止panic过程参考13.3小节):
如何使用内建函数`recover`停止`panic`过程参考13.3小节):
```go
func protect(g func()) {

View File

@@ -37,6 +37,7 @@ for {
或者使用1自动检测。
3如何通过一个通道让主程序等待直到协程完成
(信号量模式):
```go
@@ -72,7 +73,7 @@ func pump() chan int {
7如何在多核CPU上实现并行计算参考14.13小节
(8)如何停止一个协程:`runtime.Goexit()`
8如何停止一个协程:`runtime.Goexit()`
9简单的超时模板

View File

@@ -2,16 +2,17 @@
## 18.9.1 模板:
制作、解析并是模块生效:
制作、解析并是模块生效:
```go
var strTempl = template.Must(template.New(“TName”).Parse(strTemplateHTML))
```
在网页应用中使用HTML过滤器过滤HTML特殊字符
`{{html .}}` 或者通过一个字段 `FieldName {{ .FieldName |html }}`
使用缓存模板参考15.7小节)
在网页应用中使用HTML过滤器过滤HTML特殊字符
`{{html .}}` 或者通过一个字段 `FieldName {{ .FieldName |html }}`
使用缓存模板参考15.7小节)
## 链接