Course Outline
1. Introduction to Go
- Overview of Go (Golang)
- Historical context and design philosophy of Go
- Go’s role in web and systems programming
- Primary characteristics:
- Static typing
- Simplicity and clarity
- Rapid compilation
- Native concurrency
- Automatic garbage collection
- Cross-platform compilation capabilities
- Typical use cases for Go
- Strengths and limitations of the Go language
- Comparison of Go 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 Exercise: Examine and execute a basic Go program
2. Setting Up the Go Development Environment
- Installing Go
- Understanding the Go toolchain
- Configuring environment variables
- Selecting an appropriate IDE or code editor
- Interacting with Go via the command line
- Creating a Go workspace
- Understanding Go project structures
- Initialising a project using Go Modules
- Utilising
go mod init - Managing dependencies using
go get - Updating and verifying dependencies
- Formatting source code with
gofmt - Executing programs using
go run - Compiling applications using
go build - Installing Go applications
- Cross-compiling applications
- Practical Exercise: Create and configure a Go project within a container
3. Go Variables, Constants and Types
- Declaring variables
- Explicit versus inferred type definitions
- Short variable declarations
- Defining constants
- Zero values
- Variable scope and lifetime
- Primitive data types:
- Integers
- Floating-point numbers
- Complex numbers
- Booleans
- Strings
- Type conversion
- Working with Unicode and UTF-8
- Runes and bytes
- Multiple variable assignment
- Ensuring type safety
- Exercise: Develop a small command-line data processing tool
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
- Avoiding common type conversion errors
- Exercise: Implement calculation and validation logic
5. Dates, Times and Formatting
- Utilising the
timepackage - Creating and manipulating date objects
- Retrieving the current time
- Handling time zones and locations
- Parsing date and time strings
- Formatting date and time outputs
- Calculating durations
- Working with Unix timestamps
- Managing timeouts
- Exercise: Incorporate timestamps and duration calculations into an application
6. Arrays, Slices, Maps and Structs
Arrays
- Declaring arrays
- Initialising arrays
- Iterating through arrays
- Multi-dimensional arrays
Slices
- Distinguishing between slices and arrays
- Creating slices
- Appending elements to slices
- Copying slice data
- Understanding slice length and capacity
- Slicing within slices
- Common pitfalls when working with slices
Maps
- Creating map structures
- Adding and removing key-value pairs
- Verifying key existence
- Iterating through maps
- Maps containing complex data types
Structs
-
Defining struct types
-
Struct field definitions
-
Initialising struct instances
-
Nested struct compositions
-
Anonymous struct usage
-
Defining struct methods
-
Applying JSON tags to structs
-
Practical Exercise: Model users, products and application data using structs, slices and maps
7. Conditional Logic and Loops
- Using
ifstatements - Utilising
elseandelse ifclauses - Variable declarations within conditional blocks
- Implementing
forloops - Creating infinite loops
- Defining loop conditions
- Using
breakandcontinue - Iterating with
range - Nested loop structures
switchstatement usage- Expression-based switching
- Handling multiple cases
- Default case implementation
- Type-based switching
- Exercise: Implement application validation and processing logic
8. Functions
- Defining functions
- Defining function parameters
- Returning single values
- Returning multiple values
- Using named return values
- Implementing variadic functions
- Anonymous function definitions
- Working with function values
- Understanding closures
- Implementing recursion
- Passing functions as arguments
- Functions that return errors
- Designing small, reusable functions
- Exercise: Refactor existing code into reusable functions
9. Pointers and Memory Concepts
- Understanding pointers
- Address-of and dereference operators
- Pointers in function parameters
- Pointer receivers
- Pointers to struct instances
- Nil pointers
- Scenarios for using pointers
- Value versus reference semantics
- Understanding Go's memory management and garbage collection
- Common pointer-related errors
- Practical Exercise: Modify application data using pointers
10. Creating a Web Application in Go
- Overview of Go's web capabilities
- Introduction to the
net/httppackage - Creating an HTTP server
- Handling HTTP requests and responses
- Understanding HTTP methods
- Working with request URLs and query parameters
- Managing HTTP headers
- Interpreting HTTP status codes
- Routing fundamentals
- Creating request handlers
- Processing form data
- Serving static files
- Working with HTML templates
- Template variables and control structures
- Structuring a web application
- Practical Exercise: Build a basic Go web server
11. Building a RESTful Web Service
- REST architecture fundamentals
- Designing API endpoints
- Implementing GET, POST, PUT, PATCH and DELETE
- Working with JSON data
- Encoding and decoding JSON
- Request validation
- Using appropriate HTTP status codes
- Structuring error responses
- Handling query and path parameters
- Designing API response structures
- Separating handlers from business logic
- Practical Exercise: Build a CRUD REST API
12. Go Runtime, Compilation and Project Builds
- Understanding the Go compiler
- Go's build process
- Using
go run - Using
go build - Using
go install - Using
go test - Applying build flags
- Environment-specific configuration
- Building for different operating systems and architectures
- Generating standalone binaries
- Managing application configuration
- Exercise: Compile the application for multiple platforms
13. Working with Files and the Web
- Opening and closing files
- Reading file contents
- Writing to files
- Creating directories
- Retrieving file metadata
- Buffered I/O operations
- Working with data streams
- Reading and writing JSON files
- Using HTTP clients
- Making outbound HTTP requests
- Handling HTTP client errors
- Managing timeouts and cancellation
- Processing API responses
- Practical Exercise: Retrieve data from an external API and persist it locally
14. Error Handling and Debugging
- Go's approach to error management
- Returning errors from functions
- Checking for errors
- Creating custom error types
- Wrapping errors
- Adding context to error messages
- Utilising
errors.Isanderrors.As - Panic and recovery mechanisms
- Appropriate use of
panic - Debugging common Go issues
- Logging application activity
- Using Go debugging tools
- Exercise: Diagnose and fix deliberately introduced application errors
15. Interfaces and Abstraction
- Understanding interfaces
- Implicit interface implementation
- Defining interface types
- Working with interface values
- Empty interfaces and
any - Type assertions
- Type switches
- Pointer versus value implementations
- Designing small, focused interfaces
- Dependency inversion
- Using interfaces for testing
- Reducing application coupling
- Practical Exercise: Introduce interfaces into the sample web application
16. Packages and Project Organization
- Creating new packages
- Package naming conventions
- Exported and unexported identifiers
- Importing packages
- Package initialisation
- Organising application layers
- Internal package usage
- Managing dependencies with Go Modules
- Semantic versioning
- Incorporating third-party packages
- Avoiding circular dependencies
- Designing maintainable Go projects
- Exercise: Refactor the application into separate packages
17. Concurrency with Goroutines
- Concepts of concurrency
- Introduction to Goroutines
- Starting goroutines
- Understanding lightweight concurrent execution
- Synchronisation challenges
- Shared state management
- Identifying race conditions
- Using
sync.WaitGroup - Mutexes and read/write mutexes
- Atomic operations
- Practical Exercise: Convert a sequential task into concurrent processing
18. Channels
- Understanding channel mechanics
- Sending and receiving values
- Buffered versus unbuffered channels
- Blocking behaviour
- Closing channels
- Ranging over channels
- Directional channel declarations
- Channel-based communication
- Select statements
- Timeouts and cancellation
- Worker-pool patterns
- Producer/consumer patterns
- Practical Exercise: Build a concurrent worker system
19. Context and Request Management
- The importance of contexts in web applications
- Utilising
context.Context - Request-scoped context
- Cancellation mechanisms
- Setting deadlines
- Implementing timeouts
- Propagating context through application layers
- Cancelling database or HTTP operations
- Avoiding common context misuse
- Exercise: Add request cancellation and timeouts to the web application
20. Testing Go Applications
- The value of automated testing
- Writing unit tests
- Using the
testingpackage - Defining test functions
- Test naming conventions
- Table-driven testing
- Testing error handling
- Testing HTTP handlers
- Using HTTP test servers
- Managing test fixtures
- Measuring test coverage
- Performance benchmarks
- Example-based tests
- Testing interfaces with mocks or fakes
- Practical Exercise: Create a test suite for the sample application
21. Performance Optimization
- Understanding Go application performance
- Identifying performance bottlenecks
- CPU versus memory performance analysis
- Selecting efficient data structures
- Reducing unnecessary allocations
- Optimising strings, bytes and buffers
- Goroutine management
- Avoiding excessive concurrency
- Implementing caching strategies
- Database and network optimisation
- Profiling applications
- Benchmarks and performance testing
- Using Go's built-in profiling tools
- Exercise: Profile and optimise 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
- Preventing sensitive information leakage in logs
- Dependency management and security updates
- Enforcing resource limits and request timeouts
- Exercise: Review and harden the sample API
23. Application Logging and Observability
- Logging fundamentals
- Implementing structured logging
- Defining log levels
- Logging request data
- Capturing errors in logs
- Correlation and request ID tracking
- Monitoring application behaviour
- Collecting basic metrics
- Implementing health-check endpoints
- Diagnosing production issues
- Practical Exercise: Add structured logging and health checks
24. Containerizing the Go Application
- The benefits of containerisation
- Go applications and container workflows
- Writing a Dockerfile
- Utilising multi-stage builds
- Building a minimal runtime image
- Managing configuration via environment variables
- Container networking configurations
- Exposing application ports
- Running the application within a container
- Testing the containerized application
- Practical Exercise: Package the sample Go application as a production-ready container
25. Deployment
- Preparing an application for production
- Building production-grade binaries
- Configuring the environment
- Container-based deployment strategies
- Designing the deployment architecture
- Utilising reverse proxies
- HTTPS/TLS considerations
- Implementing application health checks
- Managing graceful shutdown
- Handling operating-system signals
- Scaling Go web applications
- Horizontal versus vertical scaling
- Basic deployment troubleshooting
- Practical Exercise: Deploy the sample web application
26. Capstone: Complete Go Web Application
Participants will consolidate their learning by developing a complete, functional application.
The project may incorporate the following elements:
- Project initialisation with Go Modules
- Logical package organisation
- HTTP routing implementation
- REST API endpoint development
- JSON request and response handling
- Input validation logic
- Robust error handling
- Interface-based design
- Concurrent processing capabilities
- External API communication
- File or database persistence
- Automated test suites
- Comprehensive logging
- Performance optimisation
- Containerisation strategy
- Production environment configuration
- Final deployment procedures
27. Review and Best Practices
- Review of core Go syntax
- Adherence to Go coding conventions
- Writing idiomatic Go code
- Maintaining code simplicity
- Effective package design principles
- Error-handling best practices
- Interface design guidelines
- Concurrency best practices
- Strategic testing approaches
- Performance considerations
- Ensuring maintainability and readability
- Common pitfalls for new Go developers
- Recommended pathways for continuing Go development
28. Conclusion
- Summary of key concepts
- Review of the completed web application
- Open floor for questions and discussion
- Troubleshooting common real-world scenarios
- Recommended next steps for Go development
- Additional Go libraries and ecosystem resources
- Further opportunities for building production-grade Go services
Requirements
- A foundational understanding of general programming principles
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.