您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > AI人工智能 > go(Google)语言精要
LearningGoAuthors:MiekGiebenThanksto:GoauthorsGoogleGoNutsmailinglistTHISISAWORKINPROGRESSThisworkislicensedundertheCreativeCommonsAttribution-NonCommercial-ShareAlike3.0License.Version:0.1(August16,2010)Goisfun!TableofContents1IntroductionviOfficialdocumentation..............................viiGettingGo.....................................viiOnlinedocumentation...............................viiiOrigins.......................................viiiExercises......................................ixAnswers......................................xi2Basics1HelloWorld....................................2Compilingandrunningcode...........................2Variables,typesandkeywords...........................3Operatorsandbuilt-infunctions..........................6Gokeywords....................................7Controlstructures.................................7Arrays,slicesandmaps..............................11Exercises......................................13Answers......................................153Functions18Scope.......................................19Multiplereturnvalues...............................20Namedresultparameters.............................21Deferredcode...................................22Variadicparameters................................24Functionsasvalues................................24Panicandrecovering...............................25Exercises......................................25Answers......................................274Packages32Buildingapackage.................................33Identifiers.....................................34Initialization....................................35Documentingpackages..............................35Testingpackages..................................35Advancedimporting................................37Usefulpackages..................................37Exercises......................................38Answers......................................395Beyondthebasics42Allocation.....................................42Definingyourown.................................45Interfaces.....................................46Interfacenames..................................48iiChapter:TableofContentsIntrospection...................................48Profiling......................................52Exercises......................................52Answers......................................556Concurrency58Exercises......................................60Answers......................................617Communication64Files........................................64Executingcommands...............................65Exercises......................................66Answers......................................69AExercices72Exercises......................................72Answers......................................73BArticles76Expressionversusstatement...........................76CColophon78Contributors....................................78Furtherreading..................................78DIndex80EBibliography82ListofFigures1.1ChronologyofGo................................viii2.1Arrayversusslice................................123.1AsimpleLIFOstack...............................255.1Pealingawaythelayersusingreflection.....................51ListofTables2.1Operatorprecedence..............................62.2Pre–definedfunctionsinGo...........................62.3KeywordsinGo.................................7ListofCodeExamplesiiiListofCodeExamples2.1Helloworld....................................22.2Makefileforaprogram..............................32.3Declarationwith=................................32.4Declarationwith:=................................32.5Familiartypesarestilldistinct..........................42.6Arraysandslices.................................122.7Simplefor-loop..................................152.8Loopcallsfunction................................152.9Fizz-Buzz.....................................162.10Strings......................................162.11Runesinstrings..................................173.1Afunctiondeclaration..............................183.2Localscope....................................193.3Globalscope...................................193.4Scopewhencallingfunctionsfromfunctions...................193.5Scopeandfunctionliterals............................203.6Withoutdefer..................................233.7Withdefer....................................233.8Functionliteral..................................233.9Accessreturnvalueswithindefer........................243.10Variadacparameters...............................243.11Anonymousfunction...............................243.12Functionasvaluesinmaps............................243.13Thepushandpopfunctions...........................283.14Stackusage....................................283.15stack.String()...................................283.16Stackinapackage................................293.17Afunctionwithvariablenumberofarguments.................303.18AFibonacifunctioninGo.............................
本文标题:go(Google)语言精要
链接地址:https://www.777doc.com/doc-4895732 .html