Introducing Go: Build Reliable, Scalable Programs
Caleb Doxsey
O’Reilly Media
2016
124 p
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
1. Getting Started
Machine Setup
Text Editors
The Terminal
Environment
Go
Your First Program
How to Read a Go Program
Exercises
2. Types
Numbers
Integers
Floating-Point Numbers
Example
Strings
Booleans
Exercises
3. Variables
How to Name a Variable
Scope
Constants
Defining Multiple Variables
An Example Program
Exercises
4. Control Structures
The for Statement
The if Statement
The switch Statement
Exercises
5. Arrays, Slices, and Maps
Arrays
Slices
append
copy
Maps
Exercises
6. Functions
Your Second Function
Variadic Functions
Closure
Recursion
defer, panic, and recover
panic and recover
Pointers
The * and & operators new
Exercises
7. Structs and Interfaces
Structs
Initialization
Fields
Methods
Embedded Types
Interfaces
Exercises
8. Packages
The Core Packages
Strings
Input/Output
Files and Folders
Errors
Containers and Sort
Hashes and Cryptography
Servers
TCP
HTTP
RPC
Parsing Command-Line Arguments
Creating Packages
Documentation
Exercises
9. Testing
Exercises
10. Concurrency
Goroutines
Channels
Channel Direction
Select
Buffered Channels
An Example
Exercises
11. Next Steps
Study the Masters
Make Something
Team Up
A. Answers