Course Outline
1. Introduction to Go
- What is Go (Golang)?
- Historical context and design philosophy behind Go
- Go as a language for web and systems programming
- Key characteristics:
- Static typing
- Emphasis on simplicity and readability
- High-speed compilation
- Native support for concurrency
- Automated garbage collection
- Cross-platform compilation capabilities
- Common real-world use cases for Go
- Advantages and inherent limitations of the Go language
- Comparative analysis with C/C++, JavaScript, Ruby, Python, and Java
- Understanding the broader 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
- Installing the Go toolchain
- Understanding the components of the Go toolchain
- Configuring essential environment variables
- Selecting an appropriate IDE or code editor
- Interacting with Go via the command line
- Creating a dedicated Go workspace
- Understanding the standard Go project structure
- Initialising a project using Go Modules
- Using the
go mod initcommand - Managing dependencies with
go get - Updating and inspecting project dependencies
- Formatting source code using
gofmt - Running programs with
go run - Building applications with
go build - Installing Go applications locally
- Cross-compiling applications for different architectures
- Hands-on: Create and configure a Go project within a containerised environment
3. Go Variables, Constants, and Types
- Declaring variables
- Explicit versus inferred type definitions
- Short variable declaration syntax
- Defining constants
- Understanding zero values
- Scope and lifetime of variables
- Primitive data types:
- Integers
- Floating-point numbers
- Complex numbers
- Boolean values
- Strings
- Type conversion techniques
- Working with Unicode and UTF-8 encoding
- Handling runes and bytes
- Multiple variable assignment
- Understanding type safety in Go
- Exercise: Build a small command-line data-processing program
4. Operators and Expressions
- Arithmetic operators
- Comparison operators
- Logical operators
- Assignment operators
- Increment and decrement operators
- Operator precedence rules
- Working with integer and floating-point calculations
- Avoiding common type-conversion errors
- Exercise: Implement calculations 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 dates and times for output
- Calculating time durations
- Working with Unix timestamps
- Handling operation timeouts
- Exercise: Add timestamps and duration calculations to an application
6. Arrays, Slices, Maps, and Structs
Arrays
- Declaring arrays
- Initialising array values
- Iterating over arrays
- Working with multidimensional arrays
Slices
- Understanding the difference between slices and arrays
- Creating new slices
- Appending elements to slices
- Copying slice contents
- Managing slice length and capacity
- Creating sub-slices
- Identifying common slice-related pitfalls
Maps
- Creating map structures
- Adding and removing map entries
- Checking for key existence
- Iterating over map contents
- Storing complex data types in maps
Structs
-
Defining structure types
-
Working with struct fields
-
Initialising struct instances
-
Nesting structs within other structs
-
Using anonymous struct types
-
Defining methods on structs
-
Applying JSON struct tags
-
Hands-on: Model users, products, and application data using structs, slices, and maps
7. Conditional Logic and Loops
ifstatementselseandelse ifbranches- Declaring variables within conditional blocks
forloop structures- Creating infinite loops
- Managing loop conditions
- Using
breakandcontinuestatements - Iterating with the
rangekeyword - Implementing nested loops
switchstatement structures- Expression-based switch cases
- Handling multiple cases
- Defining default cases
- Using type switches
- Exercise: Implement application validation and processing logic
8. Functions
- Defining custom functions
- Passing function parameters
- Returning single values
- Handling multiple return values
- Using named return values
- Implementing variadic functions
- Working with anonymous functions
- Treating functions as first-class values
- Utilising closures
- Implementing recursion
- Passing functions as arguments
- Designing error-returning functions
- Creating small, reusable function units
- Exercise: Refactor existing code into reusable functions
9. Pointers and Memory Concepts
- Introduction to pointers
- Using address-of and dereference operators
- Passing pointers as function parameters
- Implementing pointer receivers
- Working with pointers to structs
- Handling nil pointers
- Determining 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 using pointers
10. Creating a Web Application in Go
- Overview of Go's native web capabilities
- Introduction to the
net/httppackage - Creating an HTTP server
- Processing HTTP requests and responses
- Handling different HTTP methods
- Managing request URLs and query parameters
- Reading and writing HTTP headers
- Setting appropriate HTTP status codes
- Fundamentals of request routing
- Creating request handlers
- Processing form data submissions
- Serving static files
- Working with HTML templates
- Using template variables and control structures
- Structuring a scalable web application
- Hands-on: Build a basic Go web server
11. Building a RESTful Web Service
- REST architecture principles
- Designing API endpoints
- Implementing GET, POST, PUT, PATCH, and DELETE methods
- Working with JSON data formats
- Encoding and decoding JSON payloads
- Validating incoming requests
- Using appropriate HTTP status codes
- Structuring error responses
- Handling query and path parameters
- Designing consistent API response structures
- Separating handlers from core business logic
- Hands-on: Build a CRUD REST API
12. Go Runtime, Compilation, and Project Builds
- Understanding the Go compiler
- The Go build process
- Using
go run - Using
go build - Using
go install - Running tests with
go test - Applying build flags
- Managing environment-specific configuration
- Building for different operating systems and architectures
- Producing standalone binary executables
- Managing application configuration at runtime
- Exercise: Compile the application for multiple target platforms
13. Working with Files and the Web
- Opening and closing files
- Reading file contents
- Writing data to files
- Creating directories
- Accessing file metadata
- Utilising buffered I/O operations
- Working with data streams
- Reading and writing JSON files
- Using HTTP clients
- Making outbound HTTP requests
- Handling HTTP client errors
- Implementing timeouts and cancellation
- Processing API responses
- Hands-on: Retrieve data from an external API and persist it locally
14. Error Handling and Debugging
- Go's explicit error handling approach
- Returning errors from functions
- Checking for and handling errors
- Creating custom error types
- Wrapping errors for context
- Adding descriptive context to errors
- Using
errors.Isanderrors.As - Managing panic and recovery
- Appropriate use cases for
panic - Debugging common Go application issues
- Implementing application activity logging
- Utilising Go debugging tools
- Exercise: Diagnose and fix deliberately introduced application errors
15. Interfaces and Abstraction
- Understanding the concept of interfaces
- Implicit interface implementation
- Defining interface types
- Working with interface values
- Empty interfaces and the
anytype - Performing type assertions
- Using type switches
- Pointer versus value receiver 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 custom packages
- Following package naming conventions
- Distinguishing exported and unexported identifiers
- Importing external packages
- Package initialisation processes
- Organising application layers effectively
- Utilising internal packages
- Managing dependencies with Go Modules
- Understanding semantic versioning
- Integrating third-party packages
- Preventing circular dependencies
- Designing maintainable Go projects
- Exercise: Refactor the application into separate, logical packages
17. Concurrency with Goroutines
- Concepts of concurrency
- Introduction to Goroutines
- Starting new goroutines
- Understanding lightweight concurrent execution
- Addressing synchronisation challenges
- Managing shared state
- Preventing race conditions
- Using
sync.WaitGroup - Implementing mutexes and read/write mutexes
- Utilising atomic operations
- Hands-on: Convert a sequential task into concurrent processing
18. Channels
- Understanding channel mechanics
- Sending and receiving values
- Buffered versus unbuffered channels
- Understanding blocking behaviour
- Closing channels
- Iterating over channels using range
- Defining directional channels
- Implementing channel-based communication
- Using select statements
- Managing timeouts and cancellation
- 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
- Using
context.Context - Implementing request-scoped context
- Handling cancellation signals
- Setting deadlines
- Managing timeouts
- Propagating context through application layers
- Cancelling database or HTTP operations
- Avoiding common context misuse patterns
- Exercise: Add request cancellation and timeouts to the web application
20. Testing Go Applications
- The value of automated testing
- Writing effective unit tests
- Utilising the
testingpackage - Defining test functions
- Following test naming conventions
- Writing table-driven tests
- Testing error paths
- Testing HTTP handlers
- Using HTTP test servers
- Managing test fixtures
- Measuring test coverage
- Writing benchmarks
- Creating example tests
- Testing interfaces with mocks or fakes
- Hands-on: Create a comprehensive test suite for the sample application
21. Performance Optimization
- Understanding Go application performance metrics
- Identifying performance bottlenecks
- Optimising CPU versus memory usage
- Selecting efficient data structures
- Reducing unnecessary memory allocations
- Optimising strings, bytes, and buffers
- Managing goroutine lifecycle
- Avoiding excessive concurrency overhead
- Implementing caching strategies
- Considering database and network performance
- Profiling application behaviour
- Running benchmarks and performance tests
- Utilising 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 security vulnerabilities
- Implementing secure error handling
- Concepts of authentication and authorisation
- Managing secrets and configuration securely
- Ensuring secure HTTP communication
- Avoiding sensitive information leakage in logs
- Managing dependencies and security updates
- Enforcing resource limits and request timeouts
- Exercise: Review and harden the sample API
23. Application Logging and Observability
- Fundamentals of logging
- Implementing structured logging
- Utilising log levels
- Logging request details
- Recording errors
- Using correlation and request IDs
- Monitoring application behaviour
- Collecting basic metrics
- Implementing health-check endpoints
- Diagnosing production environment issues
- Hands-on: Add structured logging and health checks
24. Containerizing the Go Application
- Benefits of using containers
- Containerising Go applications
- Writing an effective Dockerfile
- Utilising multi-stage builds
- Building minimal runtime images
- Managing configuration via environment variables
- Configuring container networking
- Exposing application ports
- Running the application inside a container
- Testing the containerised application
- Hands-on: Package the sample Go application as a production-ready container
25. Deployment
- Preparing an application for production environments
- Building production-grade binaries
- Configuring the production environment
- Implementing container-based deployment
- Designing the deployment architecture
- Configuring reverse proxies
- Addressing HTTPS/TLS considerations
- Implementing application health checks
- Ensuring graceful shutdown
- Handling operating-system signals
- Scaling Go web applications
- Comparing horizontal versus vertical scaling
- Basic deployment troubleshooting strategies
- Hands-on: Deploy the sample web application
26. Capstone: Complete Go Web Application
Participants consolidate their learning by developing a complete, functional application.
The project may include:
- Initialising the project with Go Modules
- Organising packages logically
- Implementing HTTP routing
- Defining REST API endpoints
- Handling JSON requests and responses
- Implementing input validation
- Managing errors appropriately
- Utilising interfaces for abstraction
- Implementing concurrent processing
- Communicating with external APIs
- Implementing file or database persistence
- Writing automated tests
- Implementing structured logging
- Considering performance impacts
- Containerising the application
- Configuring for production
- Executing the deployment
27. Review and Best Practices
- Review of core Go syntax
- Adhering to Go coding conventions
- Writing idiomatic Go code
- Maintaining code simplicity
- Designing effective packages
- Following error-handling best practices
- Applying interface design principles
- Adhering to concurrency best practices
- Implementing robust testing strategies
- Considering performance implications
- Prioritising maintainability and readability
- Avoiding common mistakes made by new Go developers
- Recommended approaches for continuing professional development in Go
28. Conclusion
- Review of key concepts covered
- Review of the completed web application
- Opportunity 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.