Course Outline
1. Introduction to Go
- What is Go (Golang)?
- Historical context and design philosophy
- Go's role in web and systems programming
- Key characteristics:
- Static typing
- Simplicity and code readability
- Rapid compilation speeds
- Native concurrency support
- Garbage collection mechanisms
- Cross-platform compilation capabilities
- Common use cases for Go
- Advantages and potential limitations
- Comparative analysis with C/C++, JavaScript, Ruby, Python, and Java
- Overview of the Go ecosystem
- Introduction to the Go standard library
- Go modules and dependency management
- Anatomy of a Go application
- Practical Lab: 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 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
- Using the
go mod initcommand - Managing dependencies with
go get - Updating and inspecting dependency lists
- Formatting source code using
gofmt - Running programs with
go run - Building applications with
go build - Installing Go applications
- Cross-compiling for different platforms
- Practical Lab: Create and configure a Go project inside a container
3. Go Variables, Constants, and Types
- Declaring variables in Go
- Explicit versus inferred type definitions
- Short variable declaration syntax
- Defining constants
- Understanding zero values
- Variable scope and lifetime
- Primitive data types:
- Integers
- Floating-point numbers
- Complex numbers
- Booleans
- Strings
- Type conversion techniques
- Working with Unicode and UTF-8 encoding
- Handling Runes and bytes
- Multiple variable assignment patterns
- Understanding type safety mechanisms
- 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
- Handling integer and floating-point calculations
- Avoiding common type-conversion pitfalls
- Exercise: Implement calculation and validation logic
5. Dates, Times, and Formatting
- Utilizing the
timepackage - Creating and manipulating date objects
- Retrieving the current 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 timeouts
- Exercise: Integrate timestamps and duration calculations into an application
6. Arrays, Slices, Maps, and Structs
Arrays
- Declaring arrays
- Initializing array values
- Iterating through arrays
- Working with multidimensional arrays
Slices
- Distinguishing slices from arrays
- Creating slice instances
- Appending elements to slices
- Copying slice data
- Understanding slice length and capacity
- Sub-slicing techniques
- Common slice-related pitfalls
Maps
- Creating map structures
- Adding and removing key-value pairs
- Checking for key existence
- Iterating over map entries
- Maps containing complex data types
Structs
-
Defining custom structures
-
Managing struct fields
-
Initializing struct instances
-
Nested struct definitions
-
Using anonymous structs
-
Implementing struct methods
-
Applying JSON struct tags
-
Practical Lab: Model users, products, and application data using structs, slices, and maps
7. Conditional Logic and Loops
ifstatement syntax- Using
elseandelse ifblocks - Declaring variables within conditional statements
forloop structures- Creating infinite loops
- Defining loop termination conditions
- Using
breakandcontinuestatements - Iterating with the
rangekeyword - Nested loop implementations
switchstatement usage- Expression-based switch cases
- Handling multiple case values
- Default case behaviors
- Type-based switching
- Exercise: Implement validation and processing logic for an application
8. Functions
- Defining custom functions
- Managing function parameters
- Return value handling
- Returning multiple values
- Using named return values
- Variadic function definitions
- Working with anonymous functions
- Using functions as values
- Closure concepts
- Recursive function implementation
- Passing functions as arguments
- Designing error-returning functions
- Creating small, reusable functions
- Exercise: Refactor existing code into reusable functional blocks
9. Pointers and Memory Concepts
- Introduction to pointers
- Address-of and dereference operators
- Passing pointers as function parameters
- Implementing pointer receivers
- Pointers pointing to structs
- Handling Nil pointers
- Determining when to use pointers
- Value versus reference semantics
- Understanding Go's memory management and garbage collection
- Common pointer-related errors
- Practical Lab: Modify application data structures using pointers
10. Creating a Web Application in Go
- Overview of Go's web capabilities
- Introduction to the
net/httppackage - Setting up an HTTP server
- Processing HTTP requests and responses
- Supported HTTP methods
- Handling request URLs and query parameters
- Managing HTTP headers
- Interpreting HTTP status codes
- Fundamentals of routing
- Creating request handlers
- Processing form data
- Serving static files
- Working with HTML templates
- Template variables and control structures
- Structuring a web application architecture
- Practical Lab: Build a basic Go web server
11. Building a RESTful Web Service
- REST architecture fundamentals
- Designing API endpoints
- Using GET, POST, PUT, PATCH, and DELETE methods
- Working with JSON data formats
- Encoding and decoding JSON payloads
- Request validation strategies
- Appropriate use of HTTP status codes
- Constructing error responses
- Managing query and path parameters
- Designing API response structures
- Separating handlers from business logic
- Practical Lab: Build a CRUD REST API
12. Go Runtime, Compilation, and Project Builds
- Understanding the Go compiler
- Go's build process workflow
- Using
go run - Using
go build - Using
go install - Using
go test - Applying build flags
- Environment-specific configuration management
- Building for different 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 to files
- Creating directory structures
- Retrieving file metadata
- Using 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 response data
- Practical Lab: 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 for error occurrences
- Creating 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 activity
- Leveraging Go debugging tools
- Exercise: Diagnose and fix deliberately introduced application errors
15. Interfaces and Abstraction
- Concept of interfaces in Go
- Implicit interface implementation
- Defining interface specifications
- Working with interface values
- Empty interfaces and the
anytype - Type assertion techniques
- Using type switches
- Pointer versus value interface implementations
- Designing small, focused interfaces
- Applying dependency inversion principles
- Using interfaces to facilitate testing
- Reducing application coupling
- Practical Lab: Integrate interfaces into the sample web application
16. Packages and Project Organization
- Creating Go packages
- Package naming conventions
- Exported versus unexported identifiers
- Importing external packages
- Package initialization rules
- Organizing application architectural layers
- Using internal packages
- Managing dependencies with Go Modules
- Semantic versioning practices
- Incorporating third-party packages
- Avoiding circular dependencies
- Designing maintainable Go projects
- Exercise: Refactor the application into separate, modular packages
17. Concurrency with Goroutines
- Understanding concurrency concepts
- Introduction to Goroutines
- Starting new goroutines
- Understanding lightweight concurrent execution
- Addressing synchronization challenges
- Managing shared state
- Preventing race conditions
- Using
sync.WaitGroup - Mutexes and read/write mutexes
- Performing atomic operations
- Practical Lab: Convert a sequential task into concurrent processing
18. Channels
- Understanding channel mechanics
- Sending and receiving values
- Buffered versus unbuffered channels
- Understanding blocking behavior
- Closing channels correctly
- Ranging over channels
- Directional channel types
- Channel-based communication patterns
- Using Select statements
- Implementing timeouts and cancellations
- Worker-pool design patterns
- Producer/consumer models
- Practical Lab: Build a concurrent worker system
19. Context and Request Management
- Importance of contexts in web applications
- Using
context.Context - Request-scoped context propagation
- Implementing cancellation signals
- Setting deadlines
- Managing timeouts
- Propagating context through application layers
- Cancelling database or HTTP operations
- Avoiding common context misuse
- Exercise: Add request cancellation and timeout handling to the web application
20. Testing Go Applications
- The importance of automated testing
- Writing unit tests
- Utilizing the
testingpackage - Structuring test functions
- Test naming conventions
- Implementing table-driven tests
- Testing error conditions
- Testing HTTP handlers
- Using HTTP test servers
- Setting up test fixtures
- Measuring test coverage
- Writing performance benchmarks
- Creating example tests
- Testing interfaces with mocks or fakes
- Practical Lab: Create a comprehensive test suite for the sample application
21. Performance Optimization
- Understanding Go application performance metrics
- Identifying performance bottlenecks
- Optimizing CPU versus memory usage
- Selecting efficient data structures
- Reducing unnecessary memory allocations
- Optimizing strings, bytes, and buffers
- Managing goroutine overhead
- Avoiding excessive concurrency
- Implementing caching strategies
- Database and network optimization considerations
- Profiling application performance
- Running benchmarks and performance tests
- Using Go's built-in profiling tools
- Exercise: Profile and optimize a deliberately inefficient application
22. Security and Robust Web Application Practices
- Validating user input
- Safe handling of HTTP requests
- Preventing common web vulnerabilities
- Secure error handling practices
- Authentication and authorization concepts
- Managing secrets and configuration securely
- Ensuring secure HTTP communication
- Avoiding sensitive information leakage in logs
- Dependency management and security updates
- Enforcing resource limits and request timeouts
- Exercise: Review and harden the sample API against security threats
23. Application Logging and Observability
- Logging fundamentals
- Implementing structured logging
- Using log levels
- Request tracing and logging
- Error logging strategies
- Correlating logs with request IDs
- Monitoring application behavior
- Collecting basic metrics
- Implementing health-check endpoints
- Diagnosing production issues
- Practical Lab: Add structured logging and health check mechanisms
24. Containerizing the Go Application
- Benefits of using containers
- Go applications and containerization
- Writing an effective Dockerfile
- Using multi-stage builds
- Creating minimal runtime images
- Managing configuration via environment variables
- Container networking concepts
- Exposing application ports
- Running the application in a container
- Testing the containerized application
- Practical Lab: 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
- Container-based deployment strategies
- Designing deployment architecture
- Configuring reverse proxies
- HTTPS/TLS security considerations
- Implementing application health checks
- Handling graceful shutdown
- Responding to operating-system signals
- Scaling Go web applications
- Horizontal versus vertical scaling approaches
- Basic deployment troubleshooting
- Practical Lab: Deploy the sample web application to a production-like environment
26. Capstone: Complete Go Web Application
Participants will consolidate their learning by developing a complete, functional application.
The project may include:
- Project initialization using Go Modules
- Structured package organization
- HTTP routing implementation
- Defining REST API endpoints
- Handling JSON requests and responses
- Input validation mechanisms
- Robust error handling
- Interface implementation
- Concurrent processing logic
- External API integration
- Data persistence using files or databases
- Automated test suite
- Structured logging
- Performance optimizations
- Containerization setup
- Production configuration
- Final deployment
27. Review and Best Practices
- Review of core Go syntax
- Adhering to Go coding conventions
- Writing idiomatic Go code
- Maintaining code simplicity
- Effective package design strategies
- Error-handling best practices
- Interface design principles
- Concurrency best practices
- Testing strategies and methodologies
- Performance optimization considerations
- Ensuring maintainability and readability
- Common pitfalls for new Go developers
- Recommended paths for continuing Go development
28. Conclusion
- Recap of key concepts covered
- Review of the completed web application
- Open floor for questions and discussion
- Troubleshooting common real-world scenarios
- Recommended next steps for Go development
- Exploring additional Go libraries and ecosystem resources
- Opportunities for building production-grade Go services
Requirements
- A solid grasp of general programming concepts
Target Audience
- Software 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.