modified: eBook/18.1.md

modified:   eBook/18.11.md
	modified:   eBook/18.2.md
	modified:   eBook/18.5.md
This commit is contained in:
songleo
2016-01-03 22:15:04 +08:00
parent 8fdcfd3776
commit 63367af386
4 changed files with 6 additions and 7 deletions

View File

@@ -32,13 +32,11 @@ for ix, ch := range str {
如何获取一个字符串的字符数: 如何获取一个字符串的字符数:
最快速: 最快速:`utf8.RuneCountInString(str)`
`utf8.RuneCountInString(str)`
5如何连接字符串 5如何连接字符串
最快速: 最快速
`with a bytes.Buffer`(参考[章节7.2](07.2.md) `with a bytes.Buffer`(参考[章节7.2](07.2.md)
`Strings.Join()`(参考[章节4.7](04.7.md) `Strings.Join()`(参考[章节4.7](04.7.md)

View File

@@ -1,6 +1,6 @@
# 18.11 出于性能考虑的最佳实践和建议 # 18.11 出于性能考虑的最佳实践和建议
1尽可能的使用:=去初始化声明一个变量(在函数内部); 1尽可能的使用`:=`去初始化声明一个变量(在函数内部);
2尽可能的使用字符代替字符串 2尽可能的使用字符代替字符串

View File

@@ -1,11 +1,12 @@
# 18.2 数组和切片 # 18.2 数组和切片
创建: 创建:
`arr1 := new([len]type)` `arr1 := new([len]type)`
`slice1 := make([]type, len)` `slice1 := make([]type, len)`
初始化: 初始化:
`arr1 := [...]type{i1, i2, i3, i4, i5}` `arr1 := [...]type{i1, i2, i3, i4, i5}`
`arrKeyValue := [len]type{i1: val1, i2: val2}` `arrKeyValue := [len]type{i1: val1, i2: val2}`

View File

@@ -1,6 +1,6 @@
# 18.5 接口 # 18.5 接口
1如何检测一个值v是否实现了一个接口`Stringer` 1如何检测一个值`v`是否实现了一个接口`Stringer`
```go ```go
if v, ok := v.(Stringer); ok { if v, ok := v.(Stringer); ok {