Get Programming with Go introduces you to the powerful Go language without the confusing jargon or high-level theory. By working through over 25 quick-fire chapters, you'll quickly pick up the basics of the innovative Go programming language! Most of the examples in this book can be executed in the Go playground, so you don't need to worry about setting up a practice environment. Chock-full of engaging projects, you'll crack ancient ciphers, discover the wonders of cellular automatons, plan a vacation on Mars, and direct rovers to gather weather data!
Preface
About this book
Roadmap
Code conventions and downloads
Author Online
About the author
Unit 0: Getting started
Lesson 1 Get ready, get set, Go
1.1 What is Go?
1.2 The Go Playground
1.3 Packages and functions
1.4 The one true brace style
1.5 Summary
1.6 Try this
1.7 Answers to quick checks
Unit 1: Imperative programming
Lesson 2 A glorified calculator
2.1 Performing calculations
2.2 Formatted print
2.3 Constants and variables
2.4 Taking a shortcut
2.4.1 Declare multiple variables at once
2.4.2 Increment and assignment operators
2.5 Think of a number
2.6 Summary
2.7 Try this
2.8 Answers to quick checks
Lesson 3 Loops and branches
3.1 True or false
3.2 Comparisons
3.3 Branching with if
3.4 Logical operators
3.5 Branching with switch
3.6 Repetition with loops
3.7 Summary
Lesson 4 Variable scope
4.1 Looking into scope
4.2 Short declaration
4.3 Narrow scope, wide scope
4.4 Summary
4.5 Answers to quick checks
Lesson 5 Capstone: Ticket to Mars
Unit 2: Types
Lesson 6 Real numbers
6.1 Declaring floating point variables
6.1.1 Single precision floating point numbers
6.1.2 The zero value
6.2 Displaying floating point types
6.3 Floating point accuracy
6.4 Comparing floating point numbers
6.5 Summary
6.6 Answers to quick checks
Lesson 7 Whole numbers
7.1 Declaring integer variables
7.1.1 Integer types for every occasion
7.1.2 Knowing your type
7.2 The uint8 type for 8-bit colors
7.3 Integers wrap around
7.3.1 Look at the bits
7.3.2 Avoid wrapping around time
7.4 Summary
7.5 Answers to quick checks
Lesson 8 Big numbers
8.1 Hitting the ceiling
8.2 The big package
8.3 Constants of unusual size
8.4 Summary
Lesson 9 Multilingual text
9.1 Declaring string variables
9.2 Characters, code points, runes, and bytes
9.3 Pulling the strings
9.4 Manipulating characters with Caesar cipher
9.4.1 A modern variant
9.5 Decoding strings into runes
9.6 Summary
9.7 Answers to quick checks
Lesson 10 Converting between types
10.1 Types don't mix
10.2 Numeric type conversions
10.3 Convert types with caution
10.4 String conversions
10.5 Converting Boolean values
10.6 Summary
10.7 Answers to quick checks
Lesson 11 Capstone: The Vigenère cipher
Unit 3: Building blocks<
Lesson 12 Functions
12.1 Function declarations
12.2 Writing a function
12.3 Summary
12.4 Answers to quick checks
Lesson 13 Methods
13.1 Declaring new types
13.2 Bring your own types
13.2 Adding behavior to types with methods
13.4 Summary
13.5 Answers to quick checks
Lesson 14 First-class functions
14.1 Assigning functions to variables
14.2 Passing functions to other functions
14.3 Declaring function types
14.4 Closures and anonymous functions
14.5 Summary
14.6 Answers to quick checks
Lesson 15 Capstone
Unit 4: Collections
Lesson 16 Arrayed in splendor
16.1 Declaring arrays and accessing their elements
16.2 Don't go out of bounds
16.3 Initialize arrays with composite literals
16.4 Iterating through arrays
16.5 Arrays are copied
16.6 Multi-dimensional arrays
16.7 Summary
16.8 Answers to quick checks
Lesson 17 Slices: a window into an array
17.1 Slicing an array
17.1.1 Default indices for slicing
17.2 Composite literals for slices
17.3 The power of slices
17.4 Slices with methods
17.5 Summary
17.6 Answers to quick checks
Lesson 18 A bigger slice
18.1 The append function
18.2 Length and capacity
18.3 Investigating the append function
18.4 Three-index slicing
18.5 Preallocate slices with make
18.6 Declaring variadic functions
18.7 Summary
18.8 Answers to quick checks
Lesson 19 The ever versatile map
19.1 Declaring a map
19.2 Maps are not copied
19.3 Preallocate maps with make
19.4 Using maps to count things
19.5 Grouping data with maps and slices
19.6 Repurposing maps as sets
19.7 Summary
19.8 Answers to quick checks
Lesson 20 Capstone: A slice of life
20.1 A new universe
20.2 Looking at the universe
20.3 Seeding live cells
20.4 Implementing the game rules
20.4.1 Dead or alive?
20.4.1 Counting neighbors
20.4.3 The game logic
20.5 Parallel universe
Unit 5: State and behavior
Lesson 21 A little structure
21.1 Declaring a structure
21.2 Reusing structures with types
21.3 Initialize structures with composite literals
21.4 Structures are copied
21.5 Encoding structures to JSON
21.6 Customizing JSON with struct tags
21.7 Summary
21.8 Answers to quick checks
Lesson 22 Go's got no class
22.1 Attaching methods to structures
22.2 Constructor functions
22.3 The class alternative
22.4 Summary
22.5 Answers to quick checks
Lesson 23 Composition and forwarding
23.1 Composing structures
23.2 Forwarding methods
23.3 Name collisions
23.4 Summary
Lesson 24 Interfaces
24.1 The interface type
24.2 Discovering the interface
24.3 Satisfying interfaces
24.4 Keep interfaces small
24.5 Summary
Lesson 25 Capstone
Unit6: Down the gopher hole
Lesson 26 Pointers
Lesson 27 Nil
Lesson 28 Handling errors
Lesson 29 Capstone
Unit 7: Concurrency is not parallelism
Lesson 30 Goroutines and the runtime
Lesson 31 Communicate and synchronize with channels
Lesson 32 Channel surfing
Lesson 33 Capstone
Where to Go from here
Appendixes
Appendix A: Solutions
A.1 Lesson 1
A.2 Lesson 2
A.3 Lesson 3
A.4 Lesson 4
A.5 Lesson 5
A.6 Lesson 6
A.7 Lesson 7
A.8 Lesson 8
A.9 Lesson 9
A.10 Lesson 10
A.11 Lesson 11
A.12 Lesson 12
A.13 Lesson 13
A.14 Lesson 14
A.15 Lesson 15
A.16 Lesson 16
A.17 Lesson 17
A.18 Lesson 18
A.19 Lesson 19
A.20 Lesson 20
A.21 Lesson 21
A.22 Lesson 22
A.23 Lesson 23
A.24 Lesson 24
A.25 Lesson 25
About the Technology
Are you unsatisfied by the dichotomy between happiness-optimized scripting languages and high performance workhorse languages? Created at Google, Go is designed by and for working programmers who care about performance, reliability, and the experience of writing software. With its restrained and well considered design, Go is approachable to newcomers and refreshing for seasoned polyglots. With Go, you have the tools you need for rapidly building web, cloud, and systems applications. Best of all, it doesn't take long to become productive in Go. Are your ready?
What's inside
- Broad coverage of Go syntax and features
- A dip into the expansive standard library
- Object-oriented design without objects or class
- The nitty-gritty of memory management
FREE domestic shipping on three or more pBooks