Get in Touch

Course Outline

1. Introduction to Go

  • What is Go (Golang)?
  • History and design philosophy of Go
  • Go as a web and systems programming language
  • Key characteristics:
    • Static typing
    • Simplicity and readability
    • Fast compilation
    • Built-in concurrency
    • Garbage collection
    • Cross-platform compilation
  • Common use cases for Go
  • Advantages and limitations of Go
  • Go compared with C/C++, JavaScript, Ruby, Python and Java
  • Understanding the Go ecosystem
  • Overview of the Go standard library
  • Go modules and dependency management
  • Anatomy of a Go application
  • Hands-on: Examine and run a simple Go program

2. Setting Up the Go Development Environment

  • Installing Go
  • Understanding the Go toolchain
  • Configuring environment variables
  • Choosing an IDE or code editor
  • Using the command line with Go
  • Creating a Go workspace
  • Understanding the Go project structure
  • Initializing a project with Go Modules
  • Using go mod init
  • Managing dependencies with go get
  • Updating and inspecting dependencies
  • Formatting source code with gofmt
  • Running programs with go run
  • Building applications with go build
  • Installing Go applications
  • Cross-compiling applications
  • Hands-on: Create and configure a Go project inside a container

3. Go Variables, Constants and Types

  • Declaring variables
  • Explicit versus inferred types
  • Short variable declarations
  • Constants
  • Zero values
  • Scope and lifetime of variables
  • Primitive data types:
    • Integers
    • Floating-point numbers
    • Complex numbers
    • Booleans
    • Strings
  • Type conversions
  • Working with Unicode and UTF-8
  • Runes and bytes
  • Multiple variable assignment
  • Understanding type safety
  • Exercise: Build a small command-line data-processing program

4. Operators and Expressions

  • Arithmetic operators
  • Comparison operators
  • Logical operators
  • Assignment operators
  • Increment and decrement
  • Operator precedence
  • Working with integer and floating-point calculations
  • Avoiding common type-conversion errors
  • Exercise: Implement calculations and validation logic

5. Dates, Times and Formatting

  • Using the time package
  • Creating and manipulating dates
  • Getting the current time
  • Time zones and locations
  • Parsing dates and times
  • Formatting dates and times
  • Calculating durations
  • Working with Unix timestamps
  • Handling timeouts
  • Exercise: Add timestamps and duration calculations to an application

6. Arrays, Slices, Maps and Structs

Arrays

  • Declaring arrays
  • Initializing arrays
  • Iterating over arrays
  • Multidimensional arrays

Slices

  • Understanding slices versus arrays
  • Creating slices
  • Appending elements
  • Copying slices
  • Slice length and capacity
  • Slicing slices
  • Common slice pitfalls

Maps

  • Creating maps
  • Adding and removing entries
  • Checking whether a key exists
  • Iterating over maps
  • Maps containing complex data

Structs

  • Defining structures

  • Struct fields

  • Initializing structs

  • Nested structs

  • Anonymous structs

  • Struct methods

  • JSON struct tags

  • Hands-on: Model users, products and application data using structs, slices and maps

7. Conditional Logic and Loops

  • if statements
  • else and else if
  • Variable declarations within conditions
  • for loops
  • Infinite loops
  • Loop conditions
  • break and continue
  • Iterating with range
  • Nested loops
  • switch statements
  • Expression-based switches
  • Multiple cases
  • Default cases
  • Type switches
  • Exercise: Implement application validation and processing logic

8. Functions

  • Defining functions
  • Function parameters
  • Return values
  • Multiple return values
  • Named return values
  • Variadic functions
  • Anonymous functions
  • Function values
  • Closures
  • Recursion
  • Passing functions as arguments
  • Error-returning functions
  • Designing small, reusable functions
  • Exercise: Refactor existing code into reusable functions

9. Pointers and Memory Concepts

  • What is a pointer?
  • Address-of and dereference operators
  • Pointers and function parameters
  • Pointer receivers
  • Pointers to structs
  • Nil pointers
  • When to use pointers
  • Value versus reference semantics
  • Understanding Go's memory management and garbage collection
  • Common pointer mistakes
  • Hands-on: Modify application data using pointers

10. Creating a Web Application in Go

  • Overview of Go's web capabilities
  • Introduction to the net/http package
  • Creating an HTTP server
  • HTTP requests and responses
  • HTTP methods
  • Request URLs and query parameters
  • HTTP headers
  • HTTP status codes
  • Routing fundamentals
  • Creating handlers
  • Handling form data
  • Serving static files
  • Working with HTML templates
  • Template variables and control structures
  • Structuring a web application
  • Hands-on: Build a basic Go web server

11. Building a RESTful Web Service

  • REST architecture fundamentals
  • Designing API endpoints
  • GET, POST, PUT, PATCH and DELETE
  • Working with JSON
  • Encoding and decoding JSON
  • Request validation
  • HTTP status codes
  • Error responses
  • Query parameters and path parameters
  • API response structures
  • Separating handlers from business logic
  • Hands-on: Build a CRUD REST API

12. Go Runtime, Compilation and Project Builds

  • Understanding the Go compiler
  • Go's build process
  • go run
  • go build
  • go install
  • go test
  • Build flags
  • Environment-specific configuration
  • Building for different operating systems and architectures
  • Producing standalone binaries
  • Managing application configuration
  • Exercise: Compile the application for multiple platforms

13. Working with Files and the Web

  • Opening and closing files
  • Reading files
  • Writing files
  • Creating directories
  • File metadata
  • Buffered I/O
  • Working with streams
  • Reading and writing JSON files
  • HTTP clients
  • Making outbound HTTP requests
  • Handling HTTP client errors
  • 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 approach to errors
  • Returning errors from functions
  • Checking errors
  • Creating custom errors
  • Wrapping errors
  • Adding context to errors
  • errors.Is and errors.As
  • Panic and recovery
  • When to use panic
  • Debugging common Go problems
  • Logging application activity
  • Using Go debugging tools
  • Exercise: Diagnose and fix deliberately introduced application errors

15. Interfaces and Abstraction

  • What is an interface?
  • Implicit interface implementation
  • Defining interfaces
  • Interface values
  • Empty interfaces / any
  • Type assertions
  • Type switches
  • Pointer versus value implementations
  • Designing small interfaces
  • Dependency inversion
  • Using interfaces for testing
  • Reducing application coupling
  • Hands-on: Introduce interfaces into the sample web application

16. Packages and Project Organization

  • Creating packages
  • Package naming conventions
  • Exported and unexported identifiers
  • Importing packages
  • Package initialization
  • Organizing application layers
  • Internal packages
  • Managing dependencies with Go Modules
  • Semantic versioning
  • Using third-party packages
  • Avoiding circular dependencies
  • Designing maintainable Go projects
  • Exercise: Refactor the application into separate packages

17. Concurrency with Goroutines

  • What is concurrency?
  • Goroutines
  • Starting goroutines
  • Understanding lightweight concurrent execution
  • Synchronization challenges
  • Shared state
  • Race conditions
  • Using sync.WaitGroup
  • Mutexes and read/write mutexes
  • Atomic operations
  • Hands-on: Convert a sequential task into concurrent processing

18. Channels

  • Understanding channels
  • Sending and receiving values
  • Buffered versus unbuffered channels
  • Blocking behavior
  • Closing channels
  • Ranging over channels
  • Directional channels
  • Channel-based communication
  • Select statements
  • Timeouts and cancellation
  • Worker-pool patterns
  • Producer/consumer patterns
  • Hands-on: Build a concurrent worker system

19. Context and Request Management

  • Why contexts are important in web applications
  • context.Context
  • Request-scoped context
  • Cancellation
  • Deadlines
  • Timeouts
  • Propagating context through application layers
  • Cancelling database or HTTP operations
  • Avoiding context misuse
  • Exercise: Add request cancellation and timeouts to the web application

20. Testing Go Applications

  • Why automated testing matters
  • Writing unit tests
  • The testing package
  • Test functions
  • Test naming conventions
  • Table-driven tests
  • Testing errors
  • Testing HTTP handlers
  • HTTP test servers
  • Test fixtures
  • Test coverage
  • Benchmarks
  • Example tests
  • Testing interfaces with mocks or fakes
  • Hands-on: Create a test suite for the sample application

21. Performance Optimization

  • Understanding Go application performance
  • Identifying bottlenecks
  • CPU versus memory performance
  • Efficient data structures
  • Reducing unnecessary allocations
  • Strings, bytes and buffers
  • Goroutine management
  • Avoiding excessive concurrency
  • Caching strategies
  • Database and network considerations
  • Profiling applications
  • Benchmarks and performance testing
  • Using Go's 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
  • Authentication and authorization concepts
  • Managing secrets and configuration
  • Secure HTTP communication
  • Avoiding sensitive information in logs
  • Dependency management and updates
  • Resource limits and request timeouts
  • Exercise: Review and harden the sample API

23. Application Logging and Observability

  • Logging fundamentals
  • Structured logging
  • Log levels
  • Request logging
  • Error logging
  • Correlation and request IDs
  • Monitoring application behavior
  • Basic metrics
  • Health-check endpoints
  • Diagnosing production problems
  • Hands-on: Add structured logging and health checks

24. Containerizing the Go Application

  • Why use containers?
  • Go applications and containerization
  • Writing a Dockerfile
  • Multi-stage builds
  • Building a minimal runtime image
  • Managing configuration through environment variables
  • Container networking
  • Exposing application ports
  • Running the application in a container
  • Testing the containerized application
  • Hands-on: Package the sample Go application as a production-ready container

25. Deployment

  • Preparing an application for production
  • Building production binaries
  • Environment configuration
  • Container-based deployment
  • Deployment architecture
  • Reverse proxies
  • HTTPS/TLS considerations
  • Application health checks
  • Graceful shutdown
  • Handling 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 bring the concepts together by developing a complete application.

The project can include:

  • Project initialization with Go Modules
  • Package organization
  • HTTP routing
  • REST API endpoints
  • JSON request and response handling
  • Input validation
  • Error handling
  • Interfaces
  • Concurrent processing
  • External API communication
  • File or database persistence
  • Automated tests
  • Logging
  • Performance considerations
  • Containerization
  • Production configuration
  • Deployment

27. Review and Best Practices

  • Review of core Go syntax
  • Go coding conventions
  • Writing idiomatic Go
  • Keeping code simple
  • Effective package design
  • Error-handling best practices
  • Interface design principles
  • Concurrency best practices
  • Testing strategies
  • Performance considerations
  • Maintainability and readability
  • Common mistakes made by new Go developers
  • Recommended approaches for continuing Go development

28. Conclusion

  • Review of key concepts
  • Review of the completed web application
  • 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

  • An understanding of general programming principles

Audience

  • Developers
 28 Hours

Testimonials (5)

Upcoming Courses

Related Categories