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
- Rapid compilation speeds
- Native concurrency support
- Garbage collection mechanisms
- Cross-platform compilation capabilities
- Typical use cases for Go
- Strengths and potential limitations
- Comparative analysis with C/C++, JavaScript, Ruby, Python, and Java
- Navigating the Go ecosystem
- Introduction to the Go standard library
- Managing dependencies with Go modules
- Anatomy of a typical Go application
- Hands-on: Examine and execute a simple Go program
2. Setting Up the Go Development Environment
- Installing the Go runtime
- Understanding the Go toolchain components
- Configuring essential environment variables
- Selecting an appropriate IDE or code editor
- Interacting with Go via the command line
- Establishing a Go workspace
- Understanding Go project structure conventions
- Initializing a project using Go Modules
- Utilizing
go mod init - Managing dependencies via
go get - Updating and inspecting dependency trees
- Formatting source code with
gofmt - Executing programs using
go run - Building applications with
go build - Installing Go applications for distribution
- Cross-compiling for different platforms
- Hands-on: Create and configure a Go project within a containerized environment
3. Go Variables, Constants, and Types
- Variable declaration syntax
- Distinguishing between explicit and inferred types
- Short variable declaration techniques
- Defining constants
- Understanding zero values
- Variable scope and lifetime management
- Primitive data types:
- Integer types
- Floating-point numbers
- Complex numbers
- Boolean values
- String types
- Type conversion techniques
- Handling Unicode and UTF-8 encoding
- Workings with Runes and Bytes
- Multiple variable assignment
- Understanding Go's type safety features
- Exercise: Develop a small command-line data-processing utility
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
- Preventing 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 timestamp
- Handling time zones and locations
- Parsing date and time strings
- Formatting dates and times for display
- Calculating time durations
- Working with Unix timestamps
- Implementing timeout mechanisms
- Exercise: Integrate timestamps and duration calculations into an application
6. Arrays, Slices, Maps, and Structs
Arrays
- Declaring array instances
- Initializing array elements
- Iterating through arrays
- Working with multidimensional arrays
Slices
- Differences between slices and arrays
- Creating slice instances
- Appending elements to slices
- Copying slice data
- Understanding slice length and capacity
- Slicing existing slices
- Common pitfalls to avoid with slices
Maps
- Instantiating maps
- Adding and removing key-value entries
- Verifying key existence
- Iterating over map entries
- Maps containing complex data structures
Structs
-
Defining custom structures
-
Working with struct fields
-
Initializing struct instances
-
Nested struct configurations
-
Utilizing anonymous structs
-
Defining struct methods
-
Applying JSON struct tags
-
Hands-on: Model users, products, and application data using structs, slices, and maps
7. Conditional Logic and Loops
ifstatementselseandelse ifconstructs- Declaring variables within condition blocks
forloops- Implementing infinite loops
- Defining loop termination conditions
- Using
breakandcontinue - Iterating collections with
range - Nested loop structures
switchstatements- Expression-based switch logic
- Handling multiple cases
- Defining default cases
- Type-based switching
- Exercise: Implement application validation and processing workflows
8. Functions
- Defining custom functions
- Managing function parameters
- Returning values
- Handling multiple return values
- Using named return values
- Implementing variadic functions
- Working with anonymous functions
- Treating functions as values
- Understanding closures
- Recursive function design
- Passing functions as arguments
- Designing error-returning functions
- Crafting small, reusable functional units
- Exercise: Refactor existing code into modular, reusable functions
9. Pointers and Memory Concepts
- Fundamentals of pointers
- Address-of and dereference operators
- Pointers as function parameters
- Implementing pointer receivers
- Creating pointers to structs
- Handling nil pointers
- Determining when to use pointers
- Distinguishing value versus reference semantics
- Go's memory management and garbage collection
- Common pointer-related errors
- 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 - Instantiating an HTTP server
- Processing HTTP requests and responses
- Understanding HTTP methods
- Parsing Request URLs and query parameters
- Managing HTTP headers
- Interpreting HTTP status codes
- Routing fundamentals
- Creating request handlers
- Processing form data submissions
- Serving static assets
- Integrating HTML templates
- Template variables and control structures
- Structuring a scalable web application
- Hands-on: Develop a basic Go web server
11. Building a RESTful Web Service
- Core principles of REST architecture
- Designing efficient API endpoints
- Implementing GET, POST, PUT, PATCH, and DELETE methods
- Working with JSON data formats
- Encoding and decoding JSON payloads
- Validating incoming requests
- Appropriate use of HTTP status codes
- Constructing meaningful error responses
- Handling query and path parameters
- Standardizing API response structures
- Decoupling handlers from business logic
- Hands-on: Build a CRUD-based REST API
12. Go Runtime, Compilation, and Project Builds
- How the Go compiler works
- The Go build lifecycle
- Using
go run - Using
go build - Using
go install - Using
go test - Customizing builds with flags
- Environment-specific build configurations
- Cross-platform compilation for different OS and architectures
- Generating standalone binaries
- Managing application configuration during builds
- Exercise: Compile the application for multiple target platforms
13. Working with Files and the Web
- Opening and closing file handles
- Reading file contents
- Writing to files
- Creating directory structures
- Accessing file metadata
- Implementing Buffered I/O
- Streaming data operations
- Reading and writing JSON files
- Constructing HTTP clients
- Making outbound HTTP requests
- Handling HTTP client exceptions
- Managing timeouts and request cancellation
- Processing API response payloads
- Hands-on: Fetch data from an external API and store it locally
14. Error Handling and Debugging
- Go's explicit error handling philosophy
- Returning errors from functions
- Checking error values
- Defining custom error types
- Wrapping errors for context
- Adding descriptive context to errors
- Using
errors.Isanderrors.As - Panic and recovery mechanisms
- Appropriate use of
panic - Debugging common Go issues
- Logging application activities
- Leveraging Go debugging tools
- Exercise: Diagnose and resolve intentionally introduced application errors
15. Interfaces and Abstraction
- Conceptual understanding of interfaces
- Implicit interface satisfaction
- Defining custom interfaces
- Using interface values
- Empty interfaces and the
anytype - Type assertion techniques
- Type-switching mechanisms
- Pointer versus value interface implementations
- Designing focused, small interfaces
- Applying dependency inversion principles
- Leveraging interfaces for testability
- Reducing application coupling
- Hands-on: Integrate interfaces into the sample web application
16. Packages and Project Organization
- Creating new packages
- Following Go package naming conventions
- Distinguishing exported and unexported identifiers
- Importing external packages
- Package initialization processes
- Structuring application layers effectively
- Using internal packages
- Managing dependencies via Go Modules
- Adhering to semantic versioning
- Integrating third-party libraries
- Avoiding circular dependencies
- Designing maintainable Go projects
- Exercise: Refactor the application into modular packages
17. Concurrency with Goroutines
- Fundamentals of concurrency
- Introduction to Goroutines
- Spawning new goroutines
- Understanding lightweight concurrent execution
- Addressing synchronization challenges
- Managing shared state
- Preventing race conditions
- Using
sync.WaitGroup - Implementing Mutexes and read/write mutexes
- Performing atomic operations
- Hands-on: Convert a sequential process into concurrent processing
18. Channels
- Core concepts of channels
- Sending and receiving data via channels
- Differences between buffered and unbuffered channels
- Understanding blocking behavior
- Properly closing channels
- Iterating over channels with range
- Defining directional channels
- Channel-based communication patterns
- Using select statements
- Implementing timeouts and cancellation via channels
- Applying 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
- Utilizing
context.Context - Implementing request-scoped context
- Managing cancellation signals
- Setting deadlines
- Enforcing timeouts
- Propagating context across application layers
- Cancelling database or HTTP operations gracefully
- Avoiding common context misuse patterns
- Exercise: Implement request cancellation and timeouts in the web application
20. Testing Go Applications
- The value of automated testing
- Writing unit tests
- Using the
testingpackage - Defining test functions
- Adhering to test naming conventions
- Implementing table-driven tests
- Testing error scenarios
- Testing HTTP handlers
- Setting up HTTP test servers
- Managing test fixtures
- Measuring test coverage
- Running performance benchmarks
- Writing 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 and memory usage
- Selecting efficient data structures
- Minimizing unnecessary memory allocations
- Optimizing strings, bytes, and buffers
- Effective Goroutine management
- Preventing excessive concurrency overhead
- Implementing caching strategies
- Considerations for database and network latency
- Profiling application behavior
- Running benchmarks and performance tests
- Leveraging Go's built-in profiling tools
- Exercise: Profile and optimize a deliberately inefficient application
22. Security and Robust Web Application Practices
- Validating all user inputs
- Safe handling of HTTP requests
- Mitigating common web vulnerabilities
- Implementing secure error handling
- Authentication and authorization principles
- Secure management of secrets and configuration
- Ensuring secure HTTP communication (TLS/HTTPS)
- Preventing sensitive data leakage in logs
- Regular dependency management and updates
- Enforcing resource limits and request timeouts
- Exercise: Review and harden the security posture of the sample API
23. Application Logging and Observability
- Foundations of effective logging
- Implementing structured logging
- Utilizing log levels appropriately
- Logging HTTP requests
- Recording error details
- Using correlation and request IDs
- Monitoring application behavior
- Collecting basic operational metrics
- Implementing health-check endpoints
- Diagnosing production environment issues
- Hands-on: Add structured logging and health check capabilities
24. Containerizing the Go Application
- Benefits of containerization
- Go applications in containerized environments
- Authoring an effective Dockerfile
- Implementing multi-stage builds
- Creating minimal runtime images
- Managing configuration via environment variables
- Configuring container networking
- Exposing necessary application ports
- Running the application in a container
- Testing the containerized build
- Hands-on: Package the sample Go application as a production-ready container
25. Deployment
- Preparing an application for production launch
- Building optimized production binaries
- Configuring production environments
- Container-based deployment strategies
- Designing deployment architecture
- Integrating reverse proxies
- Considerations for HTTPS/TLS
- Implementing application health checks
- Handling graceful shutdown procedures
- Responding to operating-system signals
- Scaling Go web applications
- Horizontal versus vertical scaling strategies
- Basic deployment troubleshooting techniques
- Hands-on: Deploy the sample web application to a live environment
26. Capstone: Complete Go Web Application
Participants will synthesize all learned concepts by developing a complete, functional application.
The project may include:
- Project initialization using Go Modules
- Modular package organization
- HTTP routing implementation
- REST API endpoint development
- JSON request and response handling
- Robust input validation
- Comprehensive error handling
- Interface-driven design
- Concurrent processing implementation
- Communication with external APIs
- File or database persistence
- Automated testing suites
- Structured logging
- Performance optimization techniques
- Containerization setup
- Production environment configuration
- Deployment execution
27. Review and Best Practices
- Recap of core Go syntax
- Adhering to Go coding conventions
- Writing idiomatic Go code
- Maintaining code simplicity
- Effective package design principles
- Best practices for error handling
- Interface design guidelines
- Concurrency best practices
- Strategic testing approaches
- Performance considerations in development
- Ensuring long-term maintainability and readability
- Avoiding common pitfalls for new Go developers
- Recommended paths for advanced Go development
28. Conclusion
- Summary of key concepts covered
- Review of the completed web application
- Open Q&A and discussion session
- Troubleshooting common real-world scenarios
- Recommended next steps for your Go journey
- Additional Go libraries and ecosystem resources
- Opportunities for building production-grade Go services
Requirements
- A solid grasp of general programming principles.
Target Audience
- Developers
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.