ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
Go Fundamentals
Mark Bates
Cory LaNou
Boston Columbus New York San Francisco Amsterdam Cape Town
Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City
So Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Cover image: T-flex/Shutterstock
: Microsoft
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 or (800) 382-3419.
For government sales inquiries, please contact .
For questions about sales outside the U.S., please contact .
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2022943902
Copyright 2023 Pearson Education, Inc.
All rights reserved. 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. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearson.com/permissions.
ISBN-13: 978-0-13-791830-0
ISBN-10: 0-13-791830-5
ScoutAutomatedPrintCode
Pearsons Commitment to Diversity, Equity, and Inclusion
Pearson is dedicated to creating bias-free content that reflects the diversity of all learners. We embrace the many dimensions of diversity, including but not limited to race, ethnicity, gender, socioeconomic status, ability, age, sexual orientation, and religious or political beliefs.
Education is a powerful force for equity and change in our world. It has the potential to deliver opportunities that improve lives and enable economic mobility. As we work with authors to create content for every product and service, we acknowledge our responsibility to demonstrate inclusivity and incorporate diverse scholarship so that everyone can achieve their potential through learning. As the worlds leading learning company, we have a duty to help drive change and live up to our purpose to help more people create a better life for themselves and to create a better world.
Our ambition is to purposefully contribute to a world where
Everyone has an equitable and lifelong opportunity to succeed through learning.
Our educational products and services are inclusive and represent the rich diversity of learners.
Our educational content accurately reflects the histories and experiences of the learners we serve.
Our educational content prompts deeper discussions with learners and motivates them to expand their own learning (and worldview).
While we work hard to present unbiased content, we want to hear from you about any concerns or needs with this Pearson product so that we can investigate and address them.
Please contact us with concerns about any potential bias at https://www.pearson.com/report-bias.xhtml.
For Rachel, Dylan, Leo, and Ringo.
Mark Bates
For Karie, Logan, and Megan.
Cory LaNou
Contents
Foreword
I feel excited, honored, and a bit shocked to be writing these words.
Ive known Mark and Cory for more than a decade, and as the Go project has evolved beyond our 1.0 vision, Ive really been hoping for someone to write a follow up to the excellent Go 1.0 books. Im really grateful for the good fortune Ive had to be so deeply involved in the Go project and community. What began with me typing the first few lines of code into Hugo, over 10 years ago has exploded in ways I couldnt have dreamed of. Its been the privilege of a lifetime to lead the Go project alongside my partners Russ Cox and Sameer Ajmani and to work alongside the luminary programmers both on the Go team at Google and across the Go community.
I met Mark when we both spoke at the first Gotham Go. asked me to lead the lightning talk program and said they had the perfect partner for me. You guessed itMark. I learned that Marks stage persona was indeed who he was off stage. I also learned that he was a loyal friend who would do anything for the Go community, whose humor and courage was boundless limitless maybe a bit too much. Mark and I have paired on many stages and projects over the past 10 years, and Mark injected a spirit of excitement into everything he did. Hes become a dear friend, and Im grateful to have been on so many adventures with him.
I met Cory at the second GopherCon and instantly was drawn to him. Cory is a natural teachercaptivating and empathetic. He cares deeply about the Go community and ensuring that Go is accessible to all, especially the folks new to Go. Ive worked with him on a variety of community efforts, and Ive always come away impressed with the depth he shows in his knowledge about Go and the learning experience.
Mark and Cory have been working together for many years now as the dominant training duo for Go under the name Gopher Guides. Together they have produced excellent training programs for clients that include many notable brands found on the Fortune 500. They have expertise in both Go and in empathic learning, forged over thousands of hours of classroom-style instruction. They are the perfect pair to author what is destined to become The Go Book for Gos second phase (Go with Modules & Generics).