Perfect for beginners familiar with programming basics, this hands-on guide provides an easy introduction to Go, the general-purpose programming language from Google. Author Caleb Doxsey covers the language’s core features with step-by-step instructions and exercises in each chapter to help you practice what you learn.
Go is a general-purpose programming language with a clean syntax and advanced features, including concurrency. This book provides the one-on-one support you need to get started with the language, with short, easily digestible chapters that build on one another. By the time you finish this book, not only will you be able to write real Go programs, you'll be ready to tackle advanced techniques.
- Jump into Go basics, including data types, variables, and control structures
- Learn complex types, such as slices, functions, structs, and interfaces
- Explore Go’s core library and learn how to create your own package
- Write tests for your code by using the language’s go test program
- Learn how to run programs concurrently with goroutines and channels
- Get suggestions to help you master the craft of programming
Table of Contents
- Chapter 1Getting Started
- Machine Setup
- Your First Program
- How to Read a Go Program
- Exercises
- Chapter 2Types
- Numbers
- Strings
- Booleans
- Exercises
- Chapter 3Variables
- How to Name a Variable
- Scope
- Constants
- Defining Multiple Variables
- An Example Program
- Exercises
- Chapter 4Control Structures
- The for Statement
- The if Statement
- The switch Statement
- Exercises
- Chapter 5Arrays, Slices, and Maps
- Arrays
- Slices
- Maps
- Exercises
- Chapter 6Functions
- Your Second Function
- Variadic Functions
- Closure
- Recursion
- defer, panic, and recover
- Pointers
- Exercises
- Chapter 7Structs and Interfaces
- Structs
- Methods
- Interfaces
- Exercises
- Chapter 8Packages
- The Core Packages
- Servers
- Creating Packages
- Documentation
- Exercises
- Chapter 9Testing
- Exercises
- Exercises
- Chapter 10Concurrency
- Goroutines
- Channels
- An Example
- Exercises
- Chapter 11Next Steps
- Study the Masters
- Make Something
- Team Up
- Appendix Answers