Course Outline
1. Introduction to Go
- Overview of Go (Golang)
- Historical context and design philosophy
- Go as a language for web and systems programming
- Key characteristics:
- Static typing
- Emphasis on simplicity and readability
- Rapid compilation
- Native concurrency support
- Automatic garbage collection
- Cross-platform compilation capabilities
- Typical use cases for Go
- Advantages and potential limitations
- Comparison with C/C++, JavaScript, Ruby, Python, and Java
- Understanding the broader Go ecosystem
- Overview of the standard library
- Go modules and dependency management
- Anatomy of a Go application
- Hands-on: Examine and execute a simple Go program
2. Setting Up the Go Development Environment
- Installing Go
- Understanding the Go toolchain
- Configuring necessary environment variables
- Selecting an appropriate IDE or code editor
- Interacting with Go via the command line
- Creating a Go workspace
- Understanding standard project structures
- Initializing projects with 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 using
go build - Installing Go applications
- Cross-compiling for different architectures
- Hands-on: Create and configure a Go project within a container
3. Variables, Constants, and Data Types
- Declaring variables
- Explicit type declaration versus type inference
- Short variable declarations
- Working with constants
- Zero values and initialization
- Variable scope and lifetime
- Primitive data types:
- Integers
- Floating-point numbers
- Complex numbers
- Booleans
- Strings
- Type conversion techniques
- Handling Unicode and UTF-8
- Runes and byte sequences
- Multiple variable assignment
- Understanding type safety mechanisms
- Exercise: Develop a small command-line data processing program
4. Operators and Expressions
- Arithmetic operations
- Comparison operators
- Logical operators
- Assignment operators
- Increment and decrement operations
- Operator precedence rules
- Performing 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
- Handling time zones and locations
- Parsing date and time strings
- Formatting dates and times for output
- Calculating durations
- Working with Unix timestamps
- Implementing 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
- 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 when working with slices
Maps
- Creating map instances
- Adding and removing key-value pairs
- Checking for key existence
- Iterating over map entries
- Storing complex data types in maps
Structs
-
Defining custom structures
-
Defining struct fields
-
Initializing struct instances
-
Working with nested structures
-
Using anonymous structures
-
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 ifclauses- Declaring variables within conditions
forloops- Creating infinite loops
- Defining loop conditions
- Using
breakandcontinue - Iterating with the
rangekeyword - Nested loop structures
switchstatements- Expression-based switches
- Handling multiple cases
- Defining default cases
- Using type switches
- Exercise: Implement validation and processing logic for the application
8. Functions
- Defining functions
- Defining function parameters
- Managing return values
- Handling multiple return values
- Using named return values
- Variadic functions
- Anonymous functions (closures)
- Working with function values
- Utilizing closures
- Implementing recursion
- Passing functions as arguments
- Functions that return errors
- Designing small, reusable functions
- Exercise: Refactor existing code into reusable functional units
9. Pointers and Memory Management
- Understanding pointers
- Address-of and dereference operators
- Using pointers with function parameters
- Pointer receivers
- Pointers to structures
- Handling nil pointers
- Best practices for pointer usage
- Value semantics versus reference semantics
- Go's memory management and garbage collection
- Common pointer-related mistakes
- Hands-on: Modify application data utilizing pointers
10. Developing Web Applications with Go
- Overview of Go's web development capabilities
- Introduction to the
net/httppackage - Creating an HTTP server
- Handling HTTP requests and responses
- Supporting various HTTP methods
- Processing request URLs and query parameters
- Managing HTTP headers
- Setting appropriate HTTP status codes
- Fundamentals of routing
- Creating request handlers
- Processing form data
- Serving static files
- Working with HTML templates
- Using template variables and control structures
- Structuring web applications effectively
- Hands-on: Build a basic Go web server
11. Building RESTful Web Services
- Fundamentals of REST architecture
- Designing API endpoints
- Implementing GET, POST, PUT, PATCH, and DELETE methods
- Working with JSON data
- Encoding and decoding JSON
- Validating incoming requests
- Returning appropriate HTTP status codes
- Structuring error responses
- Handling query and path parameters
- Designing API response structures
- Separating handlers from core business logic
- Hands-on: Develop a CRUD REST API
12. Go Runtime, Compilation, and Builds
- Understanding the Go compiler
- The Go build process
- Using
go run - Using
go build - Using
go install - Using
go test - Utilizing build flags
- Configuring environment-specific settings
- Building for different operating systems and architectures
- Generating standalone binaries
- Managing application configuration
- Exercise: Compile the application for multiple target platforms
13. File Operations and Web Interaction
- Opening and closing files
- Reading file contents
- Writing data to files
- Creating directories
- Accessing file metadata
- Using buffered I/O
- Working with streams
- Reading and writing JSON files
- Utilizing 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 philosophy on error handling
- Returning errors from functions
- Checking for error conditions
- Creating custom error types
- Wrapping errors for context
- Adding context to error messages
- Using
errors.Isanderrors.As - Panic and recovery mechanisms
- Appropriate use of
panic - Debugging common Go issues
- Implementing application logging
- Utilizing Go debugging tools
- Exercise: Diagnose and resolve deliberately introduced application errors
15. Interfaces and Abstraction
- Understanding interfaces
- Implicit interface implementation
- Defining custom interfaces
- Working with interface values
- Empty interfaces and the
anytype - Performing type assertions
- Using type switches
- Pointer versus value implementations
- Designing small, focused interfaces
- Applying dependency inversion
- Using interfaces to facilitate testing
- Reducing application coupling
- Hands-on: Integrate interfaces into the sample web application
16. Packages and Project Organization
- Creating new packages
- Package naming conventions
- Exported versus unexported identifiers
- Importing packages
- Package initialization logic
- Organizing application layers
- Utilizing internal packages
- Managing dependencies with Go Modules
- Applying semantic versioning
- Incorporating third-party packages
- Avoiding circular dependencies
- Designing maintainable Go projects
- Exercise: Refactor the application into separate, logical packages
17. Concurrency with Goroutines
- Concepts of concurrency
- Understanding Goroutines
- Starting goroutines
- Lightweight concurrent execution
- Synchronization challenges
- Managing shared state
- Preventing race conditions
- Using
sync.WaitGroup - Mutexes and read/write mutexes
- Atomic operations
- Hands-on: Transform sequential tasks into concurrent processes
18. Channels
- Understanding channels
- Sending and receiving values
- Buffered versus unbuffered channels
- Blocking behavior
- Closing channels
- Iterating over channels
- Directional channels
- Channel-based communication patterns
- Using select statements
- Implementing timeouts and cancellation
- Worker-pool patterns
- 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 - Request-scoped contexts
- Implementing cancellation
- Setting deadlines
- Managing timeouts
- Propagating context through application layers
- Cancelling database or HTTP operations
- Best practices for context usage
- Exercise: Implement request cancellation and timeouts in the web application
20. Testing Go Applications
- The value of automated testing
- Writing unit tests
- Utilizing the
testingpackage - Writing test functions
- Test naming conventions
- Table-driven testing
- Testing error conditions
- Testing HTTP handlers
- Using HTTP test servers
- Creating test fixtures
- Measuring test coverage
- Running benchmarks
- Writing example tests
- Testing interfaces using mocks or fakes
- Hands-on: Create a comprehensive test suite for the sample application
21. Performance Optimization
- Understanding Go application performance
- Identifying performance bottlenecks
- CPU versus memory performance
- Selecting efficient data structures
- Reducing unnecessary memory allocations
- Optimizing strings, bytes, and buffers
- Managing goroutines
- Avoiding excessive concurrency
- Implementing caching strategies
- Considerations for database and network performance
- Profiling applications
- Conducting benchmarks and performance testing
- 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
- Safely handling HTTP requests
- Preventing common web vulnerabilities
- Implementing secure error handling
- Authentication and authorization concepts
- Managing secrets and configuration
- Ensuring secure HTTP communication
- Preventing sensitive information leaks in logs
- Managing dependencies and updates
- Setting 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 HTTP requests
- Logging errors
- Using correlation and request IDs
- Monitoring application behavior
- Collecting basic metrics
- Implementing health-check endpoints
- Diagnosing production issues
- Hands-on: Add structured logging and health checks to the application
24. Containerizing the Go Application
- The benefits of containerization
- Go applications and containers
- Writing a Dockerfile
- Implementing multi-stage builds
- Building minimal runtime images
- Managing configuration via environment variables
- Container networking
- Exposing application ports
- Running applications in containers
- Testing containerized applications
- Hands-on: Package the sample Go application as a production-ready container
25. Deployment
- Preparing applications for production
- Building production-grade binaries
- Configuring the environment
- Container-based deployment strategies
- Designing deployment architecture
- Configuring reverse proxies
- HTTPS/TLS considerations
- Implementing application health checks
- Handling graceful shutdown
- Managing operating-system signals
- Scaling Go web applications
- Horizontal versus vertical scaling
- Basic deployment troubleshooting
- Hands-on: Deploy the sample web application
26. Capstone: Complete Go Web Application
Participants will synthesize the concepts learned by developing a complete application.
The project may include the following components:
- Project initialization with Go Modules
- Organizing packages
- HTTP routing
- Defining REST API endpoints
- Handling JSON requests and responses
- Input validation
- Error handling
- Implementing interfaces
- Concurrent processing
- Communicating with external APIs
- Persisting data to files or databases
- Writing automated tests
- Implementing logging
- Considering performance optimizations
- Containerization
- Production configuration
- Deployment
27. Review and Best Practices
- Review of core Go syntax
- Go coding conventions
- Writing idiomatic Go
- Maintaining code simplicity
- Effective package design
- Error handling best practices
- Interface design principles
- Concurrency best practices
- Testing strategies
- Performance considerations
- Ensuring maintainability and readability
- Avoiding common mistakes
- Recommended approaches for continued Go development
28. Conclusion
- Review of key concepts
- Discussion of the completed web application
- Open Q&A and discussion
- Troubleshooting common real-world scenarios
- Recommended next steps for Go development
- Additional Go libraries and ecosystem resources
- Opportunities for building production-grade Go services
Requirements
- Familiarity with 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.