From the Library of YIGUANG HU The Go Programming Language From the Library of YIGUANG HU This page intentionally left blank From the Library of YIGUANG HU The Go Programming Language Alan A. A. Donovan Google Inc. Brian W. Kernighan Princeton University New York • Boston • Indianapolis • San Francisco Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City From the Library of YIGUANG HU Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The 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 herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at corpsales@pearsoned.com or (800) 382-3419. For government sales inquiries, please contact governmentsales@pearsoned.com. For questions about sales outside the United States, please contact international@pearsoned.com. Visit us on the Web: informit.com/aw Library of Congress Control Number: 2015950709 Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan All rights reserved. Printed in the United States of America. This 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. 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) 236-3290. Front cover: Millau Viaduct, Tarn valley, southern France. A paragon of simplicity in modern engineering design, the viaduct replaced a convoluted path from capital to coast with a direct route over the clouds. © Jean-Pierre Lescourret/Corbis. Back cover: the original Go gopher. © 2009 Renée French. Used under Creative Commons Attributions 3.0 license. Typeset by the authors in Minion Pro, Lato, and Consolas, using Go, groff, ghostscript, and a host of other open-source Unix tools. Figures were created in Google Drawings. ISBN-13: 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, Indiana. First printing, October 2015 From the Library of YIGUANG HU For Leila and Meg From the Library of YIGUANG HU This page intentionally left blank From the Library of YIGUANG HU Contents Preface The Origins of Go The Go Project Organization of the Book Where to Find More Information Acknowledgments xi xii xiii xv xvi xvii 1. Tutorial 1.1. Hello, World 1.2. Command-Line Arguments 1.3. Finding Duplicate Lines 1.4. Animated GIFs 1.5. Fetching a URL 1.6. Fetching URLs Concurrently 1.7. A Web Server 1.8. Loose Ends 1 1 4 8 13 15 17 19 23 2. Program Structure 2.1. Names 2.2. Declarations 2.3. Variables 2.4. Assignments 2.5. Type Declarations 2.6. Packages and Files 2.7. Scope 27 27 28 30 36 39 41 45 vii From the Library of YIGUANG HU viii 3. Basic Data Types 3.1. Integers 3.2. Floating-Point Numbers 3.3. Complex Numbers 3.4. Booleans 3.5. Strings 3.6. Constants CONTENTS 51 51 56 61 63 64 75 4. Composite Types 4.1. Arrays 4.2. Slices 4.3. Maps 4.4. Structs 4.5. JSON 4.6. Text and HTML Templates 81 81 84 93 99 107 113 5. Functions 5.1. Function Declarations 5.2. Recursion 5.3. Multiple Return Values 5.4. Errors 5.5. Function Values 5.6. Anonymous Functions 5.7. Variadic Functions 5.8. Deferred Function Calls 5.9. Panic 5.10. Recover 119 119 121 124 127 132 135 142 143 148 151 6. Methods 6.1. Method Declarations 6.2. Methods with a Pointer Receiver 6.3. Composing Types by Struct Embedding 6.4. Method Values and Expressions 6.5. Example: Bit Vector Type 6.6. Encapsul

pdf文档 The.Go.Programming.Language.2015.11

计算机 > Golang > golang > 文档预览
400 页 0 下载 814 浏览 0 评论 0 收藏 3.0分
温馨提示:如果当前文档出现乱码或未能正常浏览,请先下载原文档进行浏览。
The.Go.Programming.Language.2015.11 第 1 页 The.Go.Programming.Language.2015.11 第 2 页 The.Go.Programming.Language.2015.11 第 3 页 The.Go.Programming.Language.2015.11 第 4 页 The.Go.Programming.Language.2015.11 第 5 页
下载文档到电脑,方便使用
还有 395 页可预览,继续阅读
本文档由 user2020-12-27 06:38:01上传分享
给文档打分
您好可以输入 255 个字符
DocHub文库的中文名是什么?( 答案:多哈 )
评论列表
  • 暂时还没有评论,期待您的金玉良言