1. 首页
  2. 行业
  3. 互联网
  4. Go.in.Practice.1633430073

Go.in.Practice.1633430073

上传者: 2019-09-28 14:47:37上传 PDF文件 4.55MB 热度 41次
SummaryGo in Practice guides you through 70 real-world techniques in key areas like package management, microservice communication, and more. Following a cookbook-style Problem/Solution/Discussion format, this practical handbook builds on the foundational concepts of the Go language and introduces Go in practiceMATT BUTCHERMATT FARINAMANNINGSHELTER ISLANDFor 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.com02016 by Manning Publications Co. All rights reserveNo 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 chlorineManning Publications CoDevelopment editor: Susanna Kline20 Baldwin roadTechnical development editors: Ivan Kirkpatrick, Kim Shrier.PO Box 761Glenn burnside. Alain CouniotShelter island. ny 11964Review editor: Aleksandar DragosavljevicProject editor: Karen GulliverCopy editor: Sharon WilkeyProofreader: Melody dolabechnical proofreaderJaames frascheTypesetter: Dottie marsicoCover designer: Marija TudorISBN9781633430075Printed in the united states of america12345678910-EBM-212019181716brief contentsPART 1 BACKGROUND AND FUNDAMENTALS1■ Getting into Go32 A solid foundation 273■ Concurrency in Go59PART 2 WELL-ROUNDED APPLICATIONSe。。o。。o。。。。。。。00。。85Handling errors and panic 875 Debugging and testing 113PART 3 AN INTERFACE FOR YOUR APPLICATIONS456 HTML and email template patterns 147Serving and receiving assets and forms 1688 Working with web services 194PART 4 TAKING YOUR APPLICATIONS TO THE CLOUD....2159 Using the cloud 21710Communication between cloud services 23511Reflection and code generation 253contentsreword x2reface xUacknowledgments xviabout this book xviiiabout the authors xxabout the cover illustration xxiPART I BACKGROUND AND FUNDAMENTALSGetting into Go 31.1 What is Go? 41.2 Noteworthy aspects of go 6Multiple return values 6.A modern standard library 7Concurrency with goroutines and channels 9. Go the toolchain-more than a language 131.3 Go in the vast language landscape 17C and go17° ava and go18· Python,PHP, and Go19Javascript, Node. js, and Go 211.4 Getting up and running in Go 22Installing go 22. Working with Git, Mercurial, and versioncontrol 22. Exploring the workspace 23. Working withenvironment variables 231.5 Hello. G(O946 Summary 25CONTENTSA solid foundation 272.1 Working with CLi applications, the go way 28Command-line flags 28TECHNIQUE 1 GNU/UNIX-Style command-line arguments 31Command-line frameworks 33TechniquE 2 Avoiding cli boilerplate code 332.2 Handling configuration 38TECHNIQUE 3 Using configuration files 392.3 Working with real-world web servers 44( DaTECHNIQUE 4 Configuration via environment variables 43Starting up and shutting down a server 45TECHNIQUE 5 Graceful shutdowns using manners 46routing web requests 49TECHNIQUE 6 Matching paths to content 49TECHNIQUE 7 Handling complex paths with wildcards 52TECHNIQUE 8 URL pattern matching 54TECHNIQUE 9 Faster routing(without the work) 572.4 Summary 58Concurrency in Go 593.1 Understanding Go's concurrency model 598.2 Working with goroutines 60TECHNIQUE 10 USing goroutine closures 61TECHNIQUE 11 Waiting for goroutines 68TECHNIQUE 12 Locking with a mutex 673.3 Working with channels 72TECHNIQUE 13 Using multiple channels 73TECHNIQUE 14 Closing channels 76TECHNIQUE 15 Locking with buffered channels 808.4 Summary 82PART 2 WELL-ROUNDED APPLICATIONS .................0......854Handling errors and panics 874.1 Error handling 88g8TECHNIQUE 16 Minimize the nils 90TECHNIQUE 17 Custom error types 92TECHNIQUE 18 Error variables 93CONTENTS4.2 The panic system 95Differentiating panics from errors 96. Working with panics 97TECHNIQUE 19 Issuing panics 97Recovering from panics 99TECHNIQUE 20 Recovering from panics 100Panics and goroutines 104TECHNIQUE 21 Trapping panics on goroutines 1054.3 Summary Ill5 Debugging and testing 1135.1 Locating bugs 114Wait, where is my debugger? 1145.2 Logging 114Using Go's logger 115TECHNIQUE 22 Logging to an arbitrary writer 116TECHNIQUE 28 Logging to a network resource 118TECHNIQUE 24 Handling back pressure in network logging 120Working with system loggers 123TECHNIQUE 25 Logging to the syslog 1235.3 Accessing stack traces 126TECHNIQUE 26 Capturing stack traces 1265.4 Testing 129Unit testig129TECHNIQUE 27 Using interfaces for mocking or stubbing 130TECHNIQUE 28 Verifying interfaces with canary tests 132Generative testing 1345.5 USing performance tests and benchmarks 136TECHNIQUE 29 Benchmarking Go code 187TECHNIQUE 30 Parallel benchmarks 199TECHNIQUE 31 Detecting race conditions 1415.6 Summary 142PART 3 AN INTERFACE FOR YOUR APPLICATIONS1456HTML and email template patterns 1476.1 Working with HTML templates 148Standard library HTML package overview 148. Addingfunctionality inside templates 150
用户评论