- Go In Practice
- 1. Noteworthy aspects of Go
- 2. A solid foundation
- 3. Concurrency
- 4. Handling errors and panics
- 5. Debugging and testing
- 6. HTML and email template patterns
- 7. Serving and receiving assets and forms
- 8. Working with web services
- 9. Using the cloud
- 10. Communication between cloud services
- 11. Reflection and code generation
- Multiple returns
- Named return values
- Read TCP Status
- HTTP Get
- Concurrent output
- Using channels
- Hello world
- Testing hello world
- Hello World web server
- "Hello" CLI w/
flag
- "Hello" CLI w/
go-flags
- "Hello" CLI w/
cli.go
- Count Up/Down w/
cli.go
- Using JSON config
- Using YAML config
- Using INI config
- Using env variables
- Callback shutdown URL (anti-pattern)
- Graceful shutdown using manners
- Resolve URLs with handler functions
- Resolve URLs using
path
- Resolve URLs using RegExp
- Faster routing
- Understanding Go's CSP-based concurrency model
- Concurrent processing with goroutines
- Locking and waiting with the
sync
package and buffered channels. - Communication between goroutines using channels
- Strategically closing channels
- Using goroutines closures
- Waiting for goroutines
- Locking with a mutex
- Using multiple channels
- Closing channels
- Locking with buffered channels
- Using a goroutine to run a task
- Anonymous functions & closures
- Gzip compression tool
- Gzip compression with wait group
- Word counter
- Using multiple channels
- Pausing with
Sleep
andAfter
- Improper channel close
- Close from sender
- Close using a close channel
- Understand Go's patterns for error handling
- Using error variables and custom error types
- Providing meaningful data with errors
- Handling panics
- Transforming panics into errors
- Error handling on goroutines
An error indicates that a particular task couldn't be completed successfully. A panic indicates that a severe event ocurred, probably as a result of a programmer error.
- Minimize the nils
- Custom error types
- Error variables
- Issuing panics
- Recovering from panics
- Trapping panics on goroutines
- Returning an error
- Relying on good error handling
- Parse error
- Error variables
- Error and panic
- Recovering from panics
- Handle panics on a goroutine
- Capturing debugging information
- Using a logger (e.g., network)
- Capturing stack traces
- Writing unit tests.
- Benchmarking and acceptance tests
- Performing basic generative testing
- Detecting race conditions
- Logging to an arbitrary writer
- Logging to a network resource
- Handling back pressure in network logging
- Logging to the syslog
- Capturing stack traces
- Using interfaces for mocking or stubbing
- Verifying interfaces with canary tests
- Generative testing
- Benchmarking Go code
- Parallel benchmarks
- Detecting race conditions
- Logging to a file
- Network log client
- UDP-based logging
- Logging to syslog
- Logging to system log
- Capturing stack traces with
runtime/debug
- Capturing stack traces with
Stack
function - Hello test
- Generative test
- Benchmarking
- Two templates benchmark
- Parallel benchmarks
- Extending the functionality within templates with custom functions and pipping commands.
- Caching & buffering templates
- Template inheritance
- Nesting templates
- Mapping templates to objects, such as a user template for a user object, and rolling the templates up into a page-level output.
- Generating email output with templates
- Extending templates with functions
- Caching parsed templates
- Handling template execution failures
- Nested templates
- Template Inheritance
- Mapping data types to templates
- Generating email from templates
- Simple HTML template
- Template functions
- Cache parsed templates
- Buffer templates for error handling
- Template inheritance
- Mapping data types to templates
- Email template
- Uploading files to users from a Go server.
- Go helper functions for quick and easy access to form submissions.
- Form parsing.
- Multipart form handling.
- Serving subdirectories
- File server with custom error pages
- Caching file server
- Embedding files in a binary
- Serving from an alternative location
- Accessing multiple values for a form field
- Uploading a single file
- Uploading multiple files
- Verify uploaded file is allowed type
- Incrementally saving a file (mutlipart data)
- http package file serving
- Serve file with custom handler
- Serve subdirectories with
http.Dir
handler - Serve subdirectories with
path
handler - File not found error handler
- Cache serving
- Embedding files in a binary
- Serving from alternative location
- Parsing a simple form from response
- Parsing multiple values from form
- A form with a single-value file-upload field
- Multiple file uploads
- Detecting network timeouts.
- Resuming downloads when timeouts occur.
- Parsing errors between API endpoints and client requestors.
- Parsing JSON, even when you don't know the schema ahead of time.
- Versioning REST APIs with url and content-type.
- Detecting timeouts
- Timing out and resuming with HTTP
- Custom HTTP error passing
- Reading custom errors
- Parsing JSON without knowing the schema
- API version in the URL
- API version in content type
- A simple HTTP get
- Delete request with default http client
- Simple custom HTTP client
- Detecting timeouts and resuming with HTTP
- Passing an error over HTTP
- Custom JSON error response
- Convert HTTP response to an error
- Parsing JSON
- Parsing JSON with no schema
- API versioning in the URL
- API versioning in the content type
- Request API with content type versioning
- Working with multiple cloud providers avoiding vendor lock-in.
- Gathering information about the host.
- Compiling to various operating systems and architectures.
- Monitoring the Go runtime to detect issues and details about a running application.
- Working with multiple cloud providers
- Cleanly handling cloud provider errors
- Gathering information on the host
- Detecting dependencies
- Cross-compiling
- Monitoring the Go runtime
- Simple file storage
- Handling cloud provider errors
- Gathering information on the host
- Detecting dependencies
- Monitoring the Go runtime
- Communications in a microservice architecture.
- Reusing connections to improve performance by avoiding repeated TCP slow-start, congestion-control ramp-ups and connection negotiations.
- Faster JSON mashaling and unmarshaling that avoids extra time spent reflecting.
- Communicating over RPC using gRPC.
- Reusing connections
- Faster JSON marshal and unmarshal
- Using protocol buffers
- Communicating over RPC with protocol buffers
- Faster JSON marshal and unmarshal
- Protocol buffer file
- Protocol buffer server
- Protocol buffer client
- RPC proto file
- gRPC server
- Use kinds to identify critical details about types.
- Determine at runtime whether a type implements an interface.
- Access struct fields at runtime.
- Work with annotations.
- Parse tags within struct annotations.
- Write marshal and unmarshal functions.
- Use
go generate
. - Write Go templates that generate Go code.