Go: Beyond the Basics
Join Brian Ketelsen for a hands-on, practical exploration of advanced topics in Go. Using labs and live coding sessions, Brian takes you beyond the Go you know to the advanced concepts that will help you create faster, more robust, and more maintainable applications.
You’ll learn the right way to manage errors, how to handle communications with unreliable external services, how to benchmark and profile your applications, and how to find and fix hotspots and bottlenecks in your applications, as well as patterns and techniques to make your code easier to test. By the end of the training, your code will look like it belongs in Go’s standard library.
Whether you’re building web applications, network services, or command-line applications, the skills you’ll master in this course will take you—and your Go applications—to the next level.
What you'll learn-and how you can apply it
By the end of this live, hands-on course, you’ll understand:
- How to write idiomatic Go code that is concise, fast, and easy to test
- How to use Go’s powerful interfaces to enable code reuse
- How to use more of Go’s standard library and reduce your dependencies on external code
- When and how to use Go’s powerful concurrency primitives like mutexes and channels
And you’ll be able to:
- Gracefully handle errors
- Build applications that are more resilient, easier to monitor, and easier to maintain
This training course is for you because...
- You are an experienced Go developer ready to take your applications to the next level of professionalism and reliability
- You have created some Go applications in your organization, and it’s time to take them into production
- You have a team of Go developers looking for best practices and advanced techniques to build a sustainable Go ecosystem at your company
- Experience building Go applications
- A basic understanding of Go concepts (e.g., types, functions, and interfaces)
- Experience using code from Go’s standard library or external Go packages written by other people
Materials or downloads needed in advance:
- A Go compiler, configured to work on your computer
- Your favorite code editor
About your instructor
Brian Ketelsen is an experienced leader of technical teams with a strong focus on data warehouses and distributed computing. Writing software for various platforms since 1993, Brian has honed his broad technical skills in a variety of roles ranging from DBA to CIO. A prolific open source enthusiast, he has contributed to some of the largest Go projects, including Docker, Kubernetes, etcd, SkyDNS, Kong, Go-Kit, and Goa.
Brian cowrote Go in Action (Manning Press) and spends much of his free time fostering the Go community. He co-organizes GopherCon, the yearly conference for Go programmers held each summer in Denver, and helps organize the Tampa Go Meetup. Brian holds a bachelor’s degree in computer science.
The timeframes are only estimates and may vary according to how the class is progressing
Writing code like the Go team (30 minutes)
In the first section of the course, you’ll learn to make your code look like it belongs in Go’s standard library—and why that’s important. We’ll cover how to organize your code into packages and what those packages should contain.
- Naming conventions
- Source code conventions
Effective error management (30 minutes)
You’ll learn how to effectively handle errors in Go by exploring wrong ways to handle errors and better alternatives. You’ll learn when it’s appropriate to handle an error and when it’s appropriate to pass it back up the call stack.
- Comparing errors with known types
- Exporting errors
- Libraries are different
- Annotating errors
- Wrapping errors for clarity
Embracing the standard library (30 minutes)
You’ll learn how to get the most out of Go’s amazing standard library. We’ll look at several standard library packages that are highly useful but often ignored.
- Hidden gems in Go’s standard library
- Common interfaces
- Using stdlib for maximum effect
Creating useful interfaces (30 minutes)
We’ll look at Go’s interfaces and learn how to employ them for maximum flexibility and code reuse. We’ll explore several interfaces from the standard library.
- What makes a good interface
- Standard library interface examples
- Interface size versus interface utility
Wrangling concurrency (60 minutes)
You’ll learn when and how to use channels and mutexes and how to detect and prevent data races and concurrency errors. You’ll get practical experience using tools like sync.WaitGroup and sync.ErrorGroup.
- Race detection
Profiling and benchmarking (60 minutes)
We’ll explore making your application faster with Go’s tools for profiling, benchmarking, and optimization. Live demonstrations of profiling and optimization workflows and hands-on labs will give you firsthand experience.
- pprof and debug/pprof
- Go tool trace
Writing fast code the first time (30 minutes)
We’ll explore techniques for creating fast code. You’ll learn how to minimize garbage created in your application and build reusable pools of expensive resources.
- Arrays and slices
- Make GC faster by creating less garbage
- Avoiding unnecessary conversions
- Use the stack
Real-world testing (30 minutes)
We’ll explore real-world code from open-source Go projects to learn how to write testable code. You’ll discover how to create packages, functions, and types that are more testable.
- Writing testable code
- Interfaces and mocks
- Integration tests
- Testing hard-to-test code
Writing scalable services (30 minutes)
We’ll cover advanced patterns and techniques for building applications that scale beyond your staging environment. You’ll learn how to prevent resource exhaustion by using timeouts and cancellations.
- Timeouts and cancellations using Contexts
- Measuring throughput
- Determining your limits
- Measuring, monitoring, and logging
Q&A (30 minutes)