Golang Book Examples
1. Getting Started
- Introducing Go
- Installing Go
- Setting Up Your Environment
- Writing Your First Go Program: Hello World
2. Understanding Types
- What Is a Data Type?
- Differentiating Between Static and Dynamic Typing
- Implementing Booleans
- Understanding Numeric Types
- Checking the Type of a Variable
- Converting Between Types
3. Understanding Variables
- What Is a Variable?
- Declaring Shorthand Variables
- Understanding Variables and Zero Values
- Writing a Short Variable Declaration
- Styles of Variable Declaration
4. Using Functions in Go
- What Is a Function?
- Defining Variadic Functions
- Using Named Return Values
- Using Recursive Functions
- Passing Functions as Values
5. Using Control Flow
- Using the if Statement
- Using the else Statement
- Using the else if Statement
- Using Comparison Operators
- Using Arithmetic Operators
- Using Logical Operators
- Using the switch Statement
- Looping with the for Statement
- Using the defer Statement
6. Working with Arrays, Slices, Maps
- Working with Arrays
- Working with Slices
- Working with Maps
7. Using Structs and Pointers
- What Is a Struct
- Initializing a Struct
- Nesting Structs
- Creating Default Values for Structs
- Comparing Structs
- Understanding Public and Private Values
- Differentiating Between Point and Value References
8. Creating Methods And Interfaces
- Using Methods
- Creating Method Sets
- Working with Methods and Pointers
- Using Interfaces
9. Working with Strings
- Creating String Literals
- Understanding Rune Literals
- Concatenating Strings
10. Error Handling
- Handling Errors and Idiomatic Go
- Understanding the Error Type
- Creating Errors
- Formatting Errors
- Returning an Error from a Function
- Errors and Usability
- Don't panic
11. Working with Goroutines
- Understanding Concurrency
- Concurrency Versus Parallelism
- Understanding Concurrency Through a Web Browser
- Blocking and Non-Blocking Code
- Handling Concurrent Operations with Goroutines
- Using Goroutines to Manage Latency
- Defining Goroutines
12. Introducing Channels
- Using Channels
- Using Buffered Channels
- Blocking and Flow Control
- Using Channels as Function Arguments
- Employing the select Statement
- Quitting Channels
13. Packages
- Importing Packages
- Understanding Package Usage
- Using Third-Party Packages
- Installing a Third-Party Package
- Managing Third-Party Dependencies
14. Naming Conventions in Go
- Formatting Code in Go
- Using gofmt
- Configuring Text Editors
- Naming Conventions
- Using golint
- Using godoc
- Automating Workflow
15. Testing and Performance
- Testing: The Most Important Aspect of Software Development
- testing Package
- Running Table Tests
- Benchmarking in Go
- Providing Test Coverage
16. Debugging
- Logging
- Printing Data
- Using the fmt Package
- Using Delve
- Using gdb
17. Using Command Line Programs
- Operating with Inputs and Outputs
- Accessing Raw Command-Line Arguments
- Parsing Command-Line Flags
- Working with Types
- Customizing Help Text
- Creating Subcommands
- POSIX Compliance
- Installing and Sharing Command-Line Programs
18. Creating HTTP Servers
- Announcing Your Presence with the "Hello World" Web Server
- Examing Requests and Responses
- Working with Handler Functions
- Handling 404s
- Setting a Header
- Responding to Different Types of Requests
- Receiving Data from GET and POST Requests
19. Creating HTTP Clients with Go
- Understanding HTTP
- Making a GET Request
- Making a POST Request
- Gaining Further Control over HTTP Requests
- Debugging HTTP Requests
- Dealing With Timeouts
20. Working with JSON
- Introducing JSON
- Using JSON APIs
- Using JSON with Go
- Decoding JSON
- Mapping Data Types
- Working with JSON Received over HTTP
21. Working With files
- The Importance of Files
- Reading and Writing Files with the ioutil Package
- Writing to a File
- Listing a Directory
- Copying a File
- Deleting Files
- Using Files to Manage Configuration
22. Introducing Regular Expressions
- Defining Regular Expressions
- Getting Familiar with Regular Expression Syntax
- How To Validate Data Using Regular Expressions
- Using Regular Expressions for Validation
- Using Regular Expressions to Transform Data
- Parsing Data with Regular Expressions
23. Time
- Programming the Element of Time
- Putting Your Program to Sleep
- Setting a Timeout
- Using a Ticker
- Representing Time in a String format
- Working with Time structs
- Adding and Subtracting Time
- Comparing Different Time Structs
24. Deployment
- Understanding targets
- Reducing the Size of Binaries
- Using Docker
- Downling Binary Files
- Using go get
- Releasing Code with Package Managers
25. Creating a RESTful JSON API
- Managing Dependencies with dep
- Creating a HTTP Server with httprouter
- Scaffolding a REST API
- Testing HTTP Routes
- Serving JSON
- Adding Data Persistence
26. Creating a TCP Chat Server
- What is TCP?
- Using telnet
- Using the net Package
- Creating a Simple Chat Server
- Managing Client Connections
- Enabling Messaging Between Clients
- Preventing Echoes