Go in Action
Many of the normal concerns you face as an application developer are amplified by the challenges of web-scale concurrency, real-time performance expectations, multi-core support, and efficiently consuming services without constantly managing I/O blocks. Although it's possible to solve most of these www.it-ebooksinfoGo in actionWILLIAM KENNEDYWITH BRIAN KETELSENAND ERIKST MARTINMANNINGSHELTER ISLANDwww.it-ebooksinfoFor online information and ordering of this and other Manning books, please visitwww.manning.com.thepublisheroffersdiscountsonthisbookwhenorderedinquantityFor more information, please contactSpecial sales departmentManning publicC20 Baldwin roadPO BoX 761Shelter island. ny 11964Email:orders@manning.com@2016 by Manning Publications Co. All rights reservedNo part of this publication may be reproduced, stored in a retrieval system, or transmitted, inany form or by means electronic, mechanical, photocopying, or otherwise, without prior writtenpermission of the publisher:Many of the designations used by manufacturers and sellers to distinguish their products areclaimed as trademarks. Where those designations appear in the book, and manningPublications was aware of a trademark claim, the designations have been printed in initial capsor all capo Recognizing the importance of preserving what has been written, it is Manning,'s policy to havethe books we publish printed on acid-free paper, and we exert our best efforts to that endRecognizing also our responsibility to conserve the resources of our planet, Manning bookare printed on paper that is at least 15 percent recycled and processed without the use ofelemental chlorinManning Publications CoDevelopment editor: Jennifer Stout20 Baldwin roadTechnical development editor: Kim ShriPO Box 761Copyeditor: Jodie AllenShelter island.nY 11964Proofreader: Katie tennantechnical proofreader: Jimmy FrascheTypesetter: Dottie marsicoCover designer: Marija TudoISBN9781617991784Printed in the united states of america12345678910-EBM-201918171615www.it-ebooksinfobrief contents1 Introducing GoGo quick-start 93 Packaging and tooling 394 Arrays, slices, and maps 575 Go's type system 886 Concurrency 1287 Concurrency patterns 1588Standard library 1849 Testing and benchmarking 211www.it-ebooksinfowww.it-ebooksinfocontentsforeword xireface x222acknowledgments xivabout this book xuiabout the cover illustration xixIntroducing Go I1 Solving modern programming challenges with Go 2Development speed 3: Concurrency 3. Go's type system 5Memory management 71.2 Hello, Go 7Introducing the go Playground 81.8 Summary 8Go quick-start 92.1 Program architecture 102.2 Main package Il2.3 Search package 18search go 14. feed. go 22. match. go/default go 262.4 RSS matcher 32.5 Summary 38www.it-ebooksinfoCONTENTSPackaging and tooling 393.1 Packages 40Package-naming conventions 40- Package main 403.2 Imports 42Remote imports 42. Named imports 438.3 init 443.4 Using Go tools 458.5 Going farther with Go developer tools 47go vet47· Go format48· Go documentation483.6 Collaborating with other Go developers 51Creating repositories for sharing 513.7 Dependency management 52Vendoring dependencies 52 .Introducing gb 543.8 Summary 56Arrays, slices, and maps 574.1 Array internals and fundamentals 57Internals 58. Declaring and initializing 58. Working witharrays 60: Multidimensional arrays 62. Passing arraysbetween functions 644.2 Slice internals and fundamentals 65Internals 65. Creating and initializing 65. Working withslices 68. Multidimensional slices 79. Passing slices betweenfunctions 804.8 Map internals and fundamentals 81Internals 81. Creating and initializing 83. Working withmaps 84. Passing maps between functions 864.4 Summary 875 Go's type system 885.1 User-defined types 895.2 Methods 925.8 The nature of types 96Built-in types96· Reference types97· Struct typeswww.it-ebooksinfoCONTENTS5.4 Interfaces 101Standard library 102. Implementation 104: Methodsets 105. Polymorphism 1095.5 Type embedding lll5. 6 Exporting and unexporting identifiers 1195.7 Summary 1276Concurrency 1286.1 Concurrency versus parallelism 1296.2 Goroutines 1326.3 Race conditions 1396.4 Locking shared resources 142Atomic functions 142. Mutexes 1456.5 Channels 147Unbuffered channels 148- Buffered channels 1536.6 Summary 157Concurrency patterns 1587.1 Runner 1587.2 Pooling1677.3Work1777.4 Summary 183Standard library 1848.1 Documentation and source code 1858.2 Logging 187Log package 187. Customized loggers 191Conclusion 1958.3 Encoding/ Decoding 196Decoding soN 196. Encoding SON 201Conclusion 2028.4 Input and output 203Writer and reader interfaces 203. Working together 205Simple curl 208 Conclusion 2108.5 Summary 210www.it-ebooksinfo
用户评论