基本信息
源码名称:Go语言经典开发.pdf
源码大小:6.51M
文件格式:.pdf
开发语言:Go
更新时间:2020-10-10
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
The.Go.Programming.Language.2015.11.pdf
The.Go.Programming.Language.2015.11.pdf
Contents Preface xi The Origins of Go xii The Go Project xiii Organizat ion of the Book xv Wh ere to Find More Infor mat ion xvi Ac knowledgments xvii 1. Tutorial 1 1.1. Hello, Wor ld 1 1.2. Command-L ine Arguments 4 1.3. Finding Duplicate Lines 8 1.4. Animated GIFs 13 1.5. FetchingaURL 15 1.6. Fetching URLs Concurrently 17 1.7. A Web Server 19 1.8. Loose End s 23 2. Program Structure 27 2.1. Names 27 2.2. Declarations 28 2.3. Variables 30 2.4. Assig nments 36 2.5. Typ e Decl arat ions 39 2.6. Packages and Files 41 2.7. Scope 45 vii The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 From the Library of YIGUANG HU ptg16105617 viii CONTENTS 3. Basic Data Typ es 51 3.1. Integers 51 3.2. Floating-Point Numbers 56 3.3. Complex Numbers 61 3.4. Booleans 63 3.5. Strings 64 3.6. Constants 75 4. Composite Typ es 81 4.1. Arrays 81 4.2. Slices 84 4.3. Maps 93 4.4. Str ucts 99 4.5. JSON 107 4.6. Text and HTML Templ ates 113 5. Func tions 119 5.1. Function Declarat ions 119 5.2. Rec ursion 121 5.3. Multiple Return Values 124 5.4. Errors 127 5.5. Function Values 132 5.6. Anonymous Func tions 135 5.7. Variadic Functions 142 5.8. Deferred Function Cal ls 143 5.9. Panic 148 5.10. Recov er 151 6. Methods 155 6.1. Method Declarations 155 6.2. Methods with a Pointer Receiver 158 6.3. Composing Types by Struct Emb edding 161 6.4. Method Values and Expressions 164 6.5. Example: Bit Vector Type 165 6.6. Encapsulation 168 7. Interfaces 171 7.1. Interfaces as Contracts 171 7.2. Int erface Types 174 7.3. Int erface Satisfac tion 175 7.4. Parsing Flags wit h flag.Value 179 7.5. Int erface Values 181 The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 From the Library of YIGUANG HU ptg16105617 CONTENTS ix 7.6. Sor ting wit h sort.Interface 186 7.7. The http.Handler Interface 191 7.8. The error Interface 196 7.9. Example: Expression Evaluator 197 7.10. Typ e As ser tions 205 7.11. Discriminat ing Error s with Typ e As ser tions 206 7.12. Quer ying Beh avior s with Int erface Typ e As ser tions 208 7.13. Typ e Sw itch es 210 7.14. Example: Token-B ased XML Decoding 213 7.15. A Fe w Wo rds of Adv ice 216 8. Gor o utines and Channels 217 8.1. Goroutines 217 8.2. Example: Con cur rent Clo ck Ser ver 219 8.3. Example: Con cur rent Ech o Server 222 8.4. Channel s 225 8.5. Looping in Paral lel 234 8.6. Example: Con cur rent Web Craw ler 239 8.7. Multiplexing wit h select 244 8.8. Example: Con cur rent Direc tor y Traversal 247 8.9. Cancellat ion 251 8.10. Example: Chat Ser ver 253 9. Concurrency with Shared Vari ables 257 9.1. Race Con dit ion s 257 9.2. Mut ual Exc lusion: sync.Mutex 262 9.3. Read/Write Mut exes: sync.RWMutex 266 9.4. Memor y Sy nchro nizat ion 267 9.5. Lazy Initializat ion: sync.Once 268 9.6. The Race Detec tor 271 9.7. Example: Con cur rent Non-Blo cking Cache 272 9.8. Goroutines and Threads 280 10. Pack ages and the Go Tool 283 10.1. Int roduc tion 283 10.2. Imp ort Pat hs 284 10.3. The Package Declarat ion 285 10.4. Imp ort Declarat ions 285 10.5. Blank Imp orts 286 10.6. Packages and Naming 289 10.7. The Go Tool 290 The Go Programming Language © 2016 Alan A. A. Donovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 From the Library of YIGUANG HU ptg16105617 x CONTENTS 11. Testing 301 11.1. The go test To ol 302 11.2. Test Func tions 302 11.3. Cov erage 318 11.4. Benchmark Func tions 321 11.5. Profiling 323 11.6. Example Func tions 326 12. Reflecti on 329 12.1. Why Reflec tion? 329 12.2. reflect.Type and reflect.Value 330 12.3. Display,aRec ursive Value Print er 333 12.4. Example: Enco ding S-E xpressions 338 12.5. Setting Var iables wit h reflect.Value 341 12.6. Example: Decoding S-E xpressions 344 12.7. Accessing Str uct Field Tags 348 12.8. Displaying the Met hods of a Typ e 351 12.9. A Wo rd of Caution 352 13. Low-L evel Pro gramming 353 13.1. unsafe.Sizeof, Alignof, and Offsetof 354 13.2. unsafe.Pointer 356 13.3. Example: Deep Equivalence 358 13.4. Cal lingCCode wit h cgo 361 13.5. Another Word of Caution 366 Index 367