Example: bankruptcy

The Go Programming Language - beyondkmp

Ptg16105617 From the Library of YIGUANG HUptg16105617 The Go Programming LanguageFrom the Library of YIGUANG HUptg16105617 This page intentionally left blank From the Library of YIGUANG HUptg16105617 The Go Programming LanguageAlan A. A. DonovanGoogle W. KernighanPrinceton UniversityNew York Boston Indianapolis San FranciscoToronto Montreal London Munich Paris MadridCapetown Sydney Tokyo Singapore Mexico CityFrom the Library of YIGUANG HUptg16105617 Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.

Programming Language Alan A. A. Donovan Google Inc. Brian W. Kernighan Princeton University ... basic dat a types, cal l-by-value param-eter passing, point ers,and above all,C’semp hasisonprogramsthatcompi letoefficient machinecodeand cooperatenatural lywit h theabstrac tions ofcur rentoperat ingsystems.

Tags:

  Programming, Basics, Language, Programming language

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of The Go Programming Language - beyondkmp

1 Ptg16105617 From the Library of YIGUANG HUptg16105617 The Go Programming LanguageFrom the Library of YIGUANG HUptg16105617 This page intentionally left blank From the Library of YIGUANG HUptg16105617 The Go Programming LanguageAlan A. A. DonovanGoogle W. KernighanPrinceton UniversityNew York Boston Indianapolis San FranciscoToronto Montreal London Munich Paris MadridCapetown Sydney Tokyo Singapore Mexico CityFrom the Library of YIGUANG HUptg16105617 Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.

2 Where those designations appear in this book, and the publisher was aware of a trade-mark claim, the designations have been printed with initial capital letters or in all e authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs.)

3 And content particular to your business, train-ing goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) government sales inquiries, please contact For questions about sales outside the United States, please contact Visit us on the Web: of Congress Control Number: 2015950709 Copyright 2016 Alan A. A. Donovan & Brian W. KernighanAll rights reserved. Printed in the United States of America. Th is publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise.

4 To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, 200 Old Tappan Road, Old Tappan, New Jersey 07675, or you may fax your request to (201) cover: Millau Viaduct, Tarn valley, southern France. A paragon of simplicity in modern engi-neering design, the viaduct replaced a convoluted path from capital to coast with a direct route over the clouds. Jean-Pierre cover: the original Go gopher. 2009 Ren e French. Used under Creative Commons Attribu-tions p e s e t by t h e aut h ors i n Mi n i on Pro, L ato, an d C ons ol a s , u s i ng G o, g roff , ghostscript, and a host of other open-source Unix tools.

5 Figures were created in Google : 978-0-13-419044-0 ISBN-10: 0-13-419044-0 Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, printing, October 2015 From the Library of YIGUANG HUptg16105617Fo rLeil aan dMe gThe Go Programming Language 2016 Alan A. A. Donovan & Brian W. Kernighanrevision 3b600c, date 29 Sep 2015 From the Library of YIGUANG HUptg16105617 This page intentionally left blank From the Library of YIGUANG HUptg16105617 Cont entsPr eface xiTheOrigins ofGoxiiTheGoPro jec txiiiOrganizat ionofthe BookxvWh ere toFindMoreInfor mat ionxviAc knowledgments xvii1.

6 Hel lo, Wor Command-L ineArguments FindingDup lic ateLines Animated GIFs FetchingaURL FetchingURLs Con cur AWe bServer Loose End s232. Pro gramStr Names Declarat ions Var iables Assig nments Typ eDecl arat ions Packages andFiles Scope 45viiThe Go Programming Language 2016 Alan A. A. Donovan & Brian W. Kernighanrevision 3b600c, date 29 Sep 2015 From the Library of YIGUANG HUptg16105617viii CONTENTS3. Basic Data Typ Int egers Float ing-Point Numbers Complex Numbers Boole Str Con stants754. Com positeTyp Arrays Slices Maps Str Text andHTMLT empl ates1135.

7 Func tions FunctionDeclarat ions Rec MultipleRetur nValues Erro FunctionValues Anony mou sFunc tions Var iadic Functions Defer red FunctionCal Panic Recov er1516. Metho Met hod Declarat ions Met hodswit haPoint ComposingTyp esby Str uct Emb Met hod Values andExpressions Example: Bit Vec tor Typ Encapsulat ion1687. Int erfaces as Contrac Int erface Typ Int erface Satisfac ParsingFlags wit Int erface Values 181 The Go Programming Language 2016 Alan A. A. Donovan & Brian W. Kernighanrevision 3b600c, date 29 Sep 2015 From the Library of YIGUANG Sor tingwit TheerrorInterface Example: Typ eAs ser tions Discriminat ingError swith Typ eAs ser tions Quer yingBeh avior swith Int erface Typ eAs ser tions Typ eSw itch Example: Token-B ased XML AFe wWo rds ofAdv ice 2168.

8 Gor o utines and Channels Example: Con cur rentClo ckSer ver Example: Con cur rentEch oServer Channel Looping inParal Example: Con cur rentWeb Craw Multiplexingwit Example: Con cur rentDirec tor Cancellat Example: ChatSer ver 2539. Concurrency withShared Vari Race Con dit ion Mut ual Exc Read/Write Mut Memor ySy nchro nizat Lazy Initializat TheRace Detec tor Example: Con cur rentNon-Blo cking Cache Goroutinesand Threads 28010. Pack agesand the Int roduc Imp ort Pat ThePackageDeclarat Imp ort Declarat ions Blank Imp Packages TheGoTool290 The Go Programming Language 2016 Alan A.

9 A. Donovan & Brian W. Kernighanrevision 3b600c, date 29 Sep 2015 From the Library of YIGUANG HUptg16105617xCONTENTS11. Testing Thego testTo tions Cov tions tions 32612. Reflecti Why Reflec tion? ,aRec ursiveValue Print Example: Enco dingS-E xpressions Setting Var iables wit Example: DecodingS-E xpressions AccessingStr uct Field Tags Displaying the Met hodsofaTyp AWo rdofCaution 35213. Low-L evel Pro ,Alignof, Example: DeepEquivalence Cal lingCCodewit Another WordofCaution 366 Index367 The Go Programming Language 2016 Alan A.

10 A. Donovan & Brian W. Kernighanrevision 3b600c, date 29 Sep 2015 From the Library of YIGUANG HUptg16105617 Pref ace Go is anopensourc eprog rammi n glang uagethatmak esiteasytobui ldsimpl e,rel iab le,an defficientsof tware. (Fro mtheGoweb sit )Go was conceive din Septemb er2007 byRob ert Gries emer,Rob Pike, and Ken Thomps on, allat Google, and was announced inNov emb er2009. Thegoals ofthe langu ageand its accom-pany ing tools weretobeexpressive, efficient in bot hcomp ilation and exe cut ion,and effec tivein writing reliableand bears a sur facesimi lar ity toC and,likeC,isatoolfor prof essionalprogrammers, achie v-ingmaximum effe ctwit hminimum it ismuchmorethananupdated versionofC.


Related search queries