ptg16091132
ptg16091132
The Go
Programming
Language
ptg16091132
This page intentionally left blank
ptg16091132
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
ptg16091132
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 trade-
mark claim, the designations have been printed with initial capital letters or in all capitals.
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 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, train-
ing 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. 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. 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 engi-
neering 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 Attribu-
tions 3.0 license.
Typeset by the authors in Minion Pro, Lato, and Consolas, using Go, gro , 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