Course Outline
1. Introduction to Go
- Overview of Go (Golang).
- Historical context and design philosophy.
- Go’s role in web and systems programming.
- Key characteristics:
- Static typing.
- Emphasis on simplicity and readability.
- Fast compilation times.
- Native support for concurrency.
- Integrated garbage collection.
- Cross-platform compilation capabilities.
- Common use cases for Go.
- Analysis of Go’s advantages and limitations.
- Comparative analysis with C/C++, JavaScript, Ruby, Python, and Java.
- Understanding the Go ecosystem.
- Overview of the Go standard library.
- Go modules and dependency management strategies.
- Anatomy of a typical Go application.
- Hands-on: Examine and execute a simple Go program.
2. Setting Up the Go Development Environment
- Installation procedures for Go.
- Understanding the Go toolchain.
- Configuring essential environment variables.
- Selecting an appropriate IDE or code editor.
- Utilizing the command line interface with Go.
- Creating a Go workspace.
- Understanding standard Go project structures.
- Initializing projects using Go Modules.
- Utilizing the
go mod initcommand. - Managing dependencies via
go get. - Updating and inspecting project dependencies.
- Formatting source code using
gofmt. - Executing programs with
go run. - Building applications using
go build. - Installing Go applications.
- Cross-compiling applications for different platforms.
- Hands-on: Create and configure a Go project within a containerized environment.
3. Go Variables, Constants and Types
- Methods for declaring variables.
- Differences between explicit and inferred types.
- Short variable declaration syntax.
- Working with constants.
- Understanding zero values.
- Variable scope and lifetime.
- Primitive data types:
- Integers.
- Floating-point numbers.
- Complex numbers.
- Booleans.
- Strings.
- Type conversion techniques.
- Handling Unicode and UTF-8.
- Distinguishing between runes and bytes.
- Multiple variable assignment patterns.
- Understanding type safety mechanisms.
- Exercise: Develop a small command-line data-processing program.
4. Operators and Expressions
- Arithmetic operators.
- Comparison operators.
- Logical operators.
- Assignment operators.
- Increment and decrement operations.
- Operator precedence rules.
- Performing integer and floating-point calculations.
- Strategies for avoiding common type-conversion errors.
- Exercise: Implement calculation and validation logic.
5. Dates, Times and Formatting
- Leveraging the
timepackage. - Creating and manipulating date objects.
- Retrieving the current system time.
- Managing time zones and locations.
- Parsing date and time strings.
- Formatting dates and times for output.
- Calculating time durations.
- Working with Unix timestamps.
- Handling operation timeouts.
- Exercise: Integrate timestamps and duration calculations into an application.
6. Arrays, Slices, Maps and Structs
Arrays
- Declaring array structures.
- Initializing array elements.
- Iterating through arrays.
- Working with multidimensional arrays.
Slices
- Differences between slices and arrays.
- Creating new slices.
- Appending elements to slices.
- Copying slice data.
- Understanding slice length and capacity.
- Sub-slicing techniques.
- Common pitfalls associated with slices.
Maps
- Creating map structures.
- Adding and removing map entries.
- Checking for key existence.
- Iterating over map key-value pairs.
- Maps containing complex data structures.
Structs
-
Defining custom structures.
-
Managing struct fields.
-
Initializing struct instances.
-
Working with nested structs.
-
Utilizing anonymous structs.
-
Implementing struct methods.
-
Using JSON struct tags.
-
Hands-on: Model users, products, and application data using structs, slices, and maps.
7. Conditional Logic and Loops
- Usage of
ifstatements. - Implementing
elseandelse ifblocks. - Declaring variables within conditional statements.
- Structuring
forloops. - Creating infinite loops.
- Defining loop conditions.
- Using
breakandcontinuestatements. - Iterating with the
rangekeyword. - Nesting loops.
- Employing
switchstatements. - Expression-based switch logic.
- Handling multiple cases.
- Utilizing default cases.
- Implementing type switches.
- Exercise: Implement application validation and processing logic.
8. Functions
- Defining new functions.
- Managing function parameters.
- Returning single values.
- Returning multiple values.
- Using named return values.
- Implementing variadic functions.
- Working with anonymous functions.
- Passing functions as values.
- Creating closures.
- Implementing recursion.
- Passing functions as arguments.
- Designing error-returning functions.
- Creating small, reusable functional units.
- Exercise: Refactor existing code into reusable functions.
9. Pointers and Memory Concepts
- Conceptual overview of pointers.
- Using address-of and dereference operators.
- Pointers in function parameter passing.
- Implementing pointer receivers.
- Using pointers to structs.
- Handling nil pointers.
- Guidelines for when to use pointers.
- Distinguishing value versus reference semantics.
- Understanding Go’s memory management and garbage collection.
- Identifying common pointer-related mistakes.
- Hands-on: Modify application data structures using pointers.
10. Creating a Web Application in Go
- Overview of Go’s web development capabilities.
- Introduction to the
net/httppackage. - Setting up an HTTP server.
- Handling HTTP requests and responses.
- Understanding HTTP methods.
- Processing request URLs and query parameters.
- Managing HTTP headers.
- Using HTTP status codes correctly.
- Fundamentals of request routing.
- Creating request handlers.
- Processing form data.
- Serving static files.
- Integrating HTML templates.
- Using template variables and control structures.
- Structuring web applications effectively.
- Hands-on: Build a basic Go web server.
11. Building a RESTful Web Service
- Fundamentals of REST architecture.
- Designing API endpoints.
- Implementing GET, POST, PUT, PATCH, and DELETE methods.
- Working with JSON data.
- Encoding and decoding JSON payloads.
- Validating incoming requests.
- Appropriate use of HTTP status codes.
- Structuring error responses.
- Handling query and path parameters.
- Designing consistent API response structures.
- Separating handler logic from business logic.
- Hands-on: Build a CRUD REST API.
12. Go Runtime, Compilation and Project Builds
- Understanding the Go compiler mechanics.
- The Go build process lifecycle.
- Usage of
go run. - Usage of
go build. - Usage of
go install. - Usage of
go test. - Configuring build flags.
- Managing environment-specific configurations.
- Building for various operating systems and architectures.
- Generating standalone binaries.
- Managing application configuration files.
- Exercise: Compile the application for multiple target platforms.
13. Working with Files and the Web
- Opening and closing file handles.
- Reading file contents.
- Writing data to files.
- Creating directory structures.
- Retrieving file metadata.
- Implementing buffered I/O.
- Working with data streams.
- Reading and writing JSON files.
- Implementing HTTP clients.
- Making outbound HTTP requests.
- Handling HTTP client errors.
- Managing timeouts and cancellations.
- Processing API responses.
- Hands-on: Retrieve data from an external API and persist it locally.
14. Error Handling and Debugging
- Go’s philosophy on error handling.
- Returning errors from functions.
- Checking and handling error values.
- Creating custom error types.
- Wrapping errors for context.
- Adding contextual information to errors.
- Using
errors.Isanderrors.As. - Implementing panic and recovery mechanisms.
- Appropriate use cases for
panic. - Debugging common Go issues.
- Logging application activity effectively.
- Utilizing Go debugging tools.
- Exercise: Diagnose and fix deliberately introduced application errors.
15. Interfaces and Abstraction
- Conceptual overview of interfaces.
- Implicit interface implementation in Go.
- Defining custom interfaces.
- Working with interface values.
- Using empty interfaces and the
anytype. - Performing type assertions.
- Implementing type switches.
- Choosing between pointer and value implementations.
- Designing small, focused interfaces.
- Applying dependency inversion principles.
- Using interfaces to facilitate testing.
- Reducing coupling within applications.
- Hands-on: Introduce interfaces into the sample web application.
16. Packages and Project Organization
- Creating new packages.
- Following package naming conventions.
- Distinguishing exported and unexported identifiers.
- Importing packages correctly.
- Managing package initialization.
- Organizing application layers.
- Utilizing internal packages.
- Managing dependencies via Go Modules.
- Implementing semantic versioning.
- Incorporating third-party packages.
- Preventing circular dependencies.
- Designing maintainable Go project structures.
- Exercise: Refactor the application into separate, logical packages.
17. Concurrency with Goroutines
- Conceptual overview of concurrency.
- Understanding Goroutines.
- Starting new Goroutines.
- Understanding lightweight concurrent execution.
- Addressing synchronization challenges.
- Managing shared state.
- Identifying race conditions.
- Using
sync.WaitGroup. - Implementing Mutexes and read/write mutexes.
- Utilizing atomic operations.
- Hands-on: Convert a sequential task into concurrent processing.
18. Channels
- Conceptual overview of channels.
- Sending and receiving values via channels.
- Differences between buffered and unbuffered channels.
- Understanding blocking behavior.
- Closing channels safely.
- Iterating over channels.
- Using directional channels.
- Implementing channel-based communication patterns.
- Using Select statements.
- Handling timeouts and cancellations.
- Implementing worker-pool patterns.
- Implementing producer/consumer patterns.
- Hands-on: Build a concurrent worker system.
19. Context and Request Management
- The importance of context in web applications.
- Working with
context.Context. - Implementing request-scoped context.
- Handling cancellation signals.
- Setting deadlines.
- Managing timeouts.
- Propagating context through application layers.
- Cancelling database or HTTP operations.
- Best practices for avoiding context misuse.
- Exercise: Add request cancellation and timeout handling to the web application.
20. Testing Go Applications
- The importance of automated testing.
- Writing effective unit tests.
- Utilizing the
testingpackage. - Structuring test functions.
- Adhering to test naming conventions.
- Implementing table-driven tests.
- Testing error scenarios.
- Testing HTTP handlers.
- Using HTTP test servers.
- Managing test fixtures.
- Monitoring test coverage.
- Writing benchmarks.
- Creating example tests.
- Testing interfaces using mocks or fakes.
- Hands-on: Create a comprehensive test suite for the sample application.
21. Performance Optimization
- Analyzing Go application performance.
- Identifying performance bottlenecks.
- Balancing CPU versus memory performance.
- Choosing efficient data structures.
- Reducing unnecessary memory allocations.
- Optimizing strings, bytes, and buffers.
- Managing Goroutine lifecycle.
- Avoiding excessive concurrency.
- Implementing caching strategies.
- Considering database and network performance.
- Profiling applications.
- Conducting benchmarks and performance testing.
- Utilizing Go’s built-in profiling tools.
- Exercise: Profile and optimize a deliberately inefficient application.
22. Security and Robust Web Application Practices
- Validating user input rigorously.
- Safely handling HTTP requests.
- Preventing common web vulnerabilities.
- Implementing secure error handling.
- Understanding authentication and authorization.
- Managing secrets and configuration securely.
- Ensuring secure HTTP communication.
- Preventing leakage of sensitive information in logs.
- Managing dependencies and updates securely.
- Enforcing resource limits and request timeouts.
- Exercise: Review and harden the sample API against security threats.
23. Application Logging and Observability
- Fundamentals of logging.
- Implementing structured logging.
- Defining log levels.
- Logging request details.
- Recording errors effectively.
- Using correlation and request IDs.
- Monitoring application behavior.
- Collecting basic metrics.
- Implementing health-check endpoints.
- Diagnosing production environment issues.
- Hands-on: Add structured logging and health checks to the application.
24. Containerizing the Go Application
- The benefits of using containers.
- Go applications and containerization best practices.
- Writing an efficient Dockerfile.
- Utilizing multi-stage builds.
- Building minimal runtime images.
- Managing configuration via environment variables.
- Configuring container networking.
- Exposing application ports correctly.
- Running the application within a container.
- Testing the containerized application.
- Hands-on: Package the sample Go application as a production-ready container.
25. Deployment
- Preparing an application for production environments.
- Building optimized production binaries.
- Managing environment configuration.
- Implementing container-based deployment.
- Designing deployment architecture.
- Configuring reverse proxies.
- Considerations for HTTPS/TLS.
- Implementing application health checks.
- Managing graceful shutdown.
- Handling operating-system signals.
- Scaling Go web applications.
- Comparing horizontal versus vertical scaling.
- Basic deployment troubleshooting techniques.
- Hands-on: Deploy the sample web application to a production-like environment.
26. Capstone: Complete Go Web Application
Participants will synthesize learned concepts by developing a complete, end-to-end application.
The project may include the following components:
- Project initialization with Go Modules.
- Logical package organization.
- HTTP routing implementation.
- REST API endpoint design.
- JSON request and response handling.
- Robust input validation.
- Comprehensive error handling.
- Interface-driven design.
- Concurrent processing implementation.
- External API integration.
- File or database persistence.
- Automated test coverage.
- Structured logging.
- Performance optimization considerations.
- Containerization setup.
- Production configuration management.
- Final deployment procedures.
27. Review and Best Practices
- Review of core Go syntax.
- Go coding conventions and standards.
- Writing idiomatic Go code.
- Maintaining code simplicity.
- Effective package design principles.
- Error-handling best practices.
- Interface design principles.
- Concurrency best practices.
- Testing strategies and methodologies.
- Performance optimization considerations.
- Ensuring maintainability and readability.
- Common mistakes made by new Go developers.
- Recommended approaches for continued Go development.
28. Conclusion
- Summary of key concepts learned.
- Review of the completed web application.
- Open Q&A and discussion session.
- Troubleshooting common real-world scenarios.
- Recommended next steps for Go development.
- Exploration of additional Go libraries and ecosystem resources.
- Further opportunities for building production-grade Go services.
Requirements
- A solid understanding of general programming principles.
Target Audience
- Developers seeking to expand their skill set with Go.
Testimonials (5)
The trainer proved himself to be an expert of the topic, which I never give for granted. He provided very useful insight on industry standards.
Giuseppe
Course - Learning Go Programming
I enjoyed the amount of hands on exercises we did. I personally learn by doing things so it was good that Francesco had lots of hands-on exercises to do. I struggled to pick up a few of the concepts from the slides but when I actually got hands on and was able to implement some of the key features of the language it helped me understand it better.
Adam Fitzhugh - OpticoreIT
Course - Learning Go Programming
tha pace, trainers ability to help and sustain slightly more difficult questions.
Andrei Mihai - Viasat
Course - Learning Go Programming
Radu's in-depth knowledge, and tailoring the pace for me.
Adeel Ahmad - Coefficient Data Ltd
Course - Learning Go Programming
Flexibility of the trainer. Really catered the course to our specific needs.