实例介绍
【实例截图】
【核心代码】
contents
foreword xi
preface xiii
acknowledgments xiv
about this book xvi
about the cover illustration xix
1
Introducing Go 1
1.1 Solving modern programming challenges with Go 2
Development speed 3
■
Concurrency 3
■
Go’s type system 5
Memory management 7
1.2 Hello, Go 7
Introducing the Go Playground 8
1.3 Summary 8
2
Go quick-start 9
2.1 Program architecture 10
2.2 Main package 11
2.3 Search package 13
search.go 14
■
feed.go 22
■
match.go/default.go 26
2.4 RSS matcher 32
2.5 Summary 38
Licensed to Mark Watson <nordickan@gmail.com>
CONTENTS viii
3
Packaging and tooling 39
3.1 Packages 40
Package-naming conventions 40
■
Package main 40
3.2 Imports 42
Remote imports 42
■
Named imports 43
3.3 init 44
3.4 Using Go tools 45
3.5 Going farther with Go developer tools 47
go vet 47
■
Go format 48
■
Go documentation 48
3.6 Collaborating with other Go developers 51
Creating repositories for sharing 51
3.7 Dependency management 52
Vendoring dependencies 52
■
Introducing gb 54
3.8 Summary 56
4
Arrays, slices, and maps 57
4.1 Array internals and fundamentals 57
Internals 58
■
Declaring and initializing 58
■
Working with
arrays 60
■
Multidimensional arrays 62
■
Passing arrays
between functions 64
4.2 Slice internals and fundamentals 65
Internals 65
■
Creating and initializing 65
■
Working with
slices 68
■
Multidimensional slices 79
■
Passing slices between
functions 80
4.3 Map internals and fundamentals 81
Internals 81
■
Creating and initializing 83
■
Working with
maps 84
■
Passing maps between functions 86
4.4 Summary 87
5
Go’s type system 88
5.1 User-defined types 89
5.2 Methods 92
5.3 The nature of types 96
Built-in types 96
■
Reference types 97
■
Struct types 98
Licensed to Mark Watson <nordickan@gmail.com>
CONTENTS ix
5.4 Interfaces 101
Standard library 102
■
Implementation 104
■
Method
sets 105
■
Polymorphism 109
5.5 Type embedding 111
5.6 Exporting and unexporting identifiers 119
5.7 Summary 127
6
Concurrency 128
6.1 Concurrency versus parallelism 129
6.2 Goroutines 132
6.3 Race conditions 139
6.4 Locking shared resources 142
Atomic functions 142
■
Mutexes 145
6.5 Channels 147
Unbuffered channels 148
■
Buffered channels 153
6.6 Summary 157
7
Concurrency patterns 158
7.1 Runner 158
7.2 Pooling 167
7.3 Work 177
7.4 Summary 183
8
Standard library 184
8.1 Documentation and source code 185
8.2 Logging 187
Log package 187
■
Customized loggers 191
Conclusion 195
8.3 Encoding/Decoding 196
Decoding JSON 196
■
Encoding JSON 201
Conclusion 202
8.4 Input and output 203
Writer and Reader interfaces 203
■
Working together 205
Simple curl 208
■
Conclusion 210
8.5 Summary 210
Licensed to Mark Watson <nordickan@gmail.com>
CONTENTS x
9
Testing and benchmarking 211
9.1 Unit testing 212
Basic unit test 212
■
Table tests 216
■
Mocking calls 219
Testing endpoints 223
9.2 Examples 228
9.3 Benchmarking 232
9.4 Summary 236
index 237
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论