Get in Touch

Course Outline

1. Introduction to Go

  • An overview of Go (Golang)
  • The history and design philosophy behind Go
  • Go as a language for web and systems programming
  • Defining characteristics:
    • Static typing
    • Simplicity and readability
    • Rapid compilation
    • Natively supported concurrency
    • Garbage collection
    • Cross-platform compilation capabilities
  • Typical use cases for Go
  • Strengths and limitations of the language
  • Comparing Go with C/C++, JavaScript, Ruby, Python, and Java
  • Navigating the Go ecosystem
  • Overview of the Go standard library
  • Go modules and dependency management
  • Structure of a Go application
  • Practical Exercise: Examine and execute a basic Go program

2. Configuring the Go Development Environment

  • Installing Go
  • Understanding the Go toolchain
  • Setting up environment variables
  • Selecting an IDE or code editor
  • Interacting with Go via the command line
  • Creating a Go workspace
  • Understanding Go project architecture
  • Initializing a project using Go Modules
  • Utilizing the go mod init command
  • Managing dependencies with go get
  • Updating and inspecting dependencies
  • Formatting source code using gofmt
  • Executing programs with go run
  • Building applications with go build
  • Installing Go applications
  • Compiling applications for different platforms
  • Practical Exercise: Create and set up a Go project within a container

3. Go Variables, Constants, and Data Types

  • Declaring variables
  • Explicit types versus inferred types
  • 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 conversions
  • Handling Unicode and UTF-8
  • Runes and bytes
  • Multiple variable assignment
  • Comprehending type safety
  • Exercise: Develop a small command-line data-processing program

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

  • Utilizing the time package
  • Generating and manipulating dates
  • Retrieving the current time
  • Time zones and geographical locations
  • Parsing date and time strings
  • Formatting dates and times
  • Calculating durations
  • Working with Unix timestamps
  • Managing timeouts
  • Exercise: Integrate timestamps and duration calculations into an application

6. Arrays, Slices, Maps, and Structs

Arrays

  • Declaring arrays
  • Initializing arrays
  • Iterating through arrays
  • Multi-dimensional arrays

Slices

  • Distinguishing between slices and arrays
  • Creating slices
  • Adding elements to slices
  • Duplicating slices
  • Understanding slice length and capacity
  • Slicing existing slices
  • Common pitfalls associated with slices

Maps

  • Creating maps
  • Inserting and deleting entries
  • Verifying key existence
  • Iterating through maps
  • Maps containing complex data structures

Structs

  • Defining structures

  • Struct fields

  • Initializing structs

  • Nested structs

  • Anonymous structs

  • Struct methods

  • JSON struct tags

  • Practical Exercise: Model users, products, and application data using structs, slices, and maps

7. Conditional Logic and Loops

  • if statements
  • else and else if constructs
  • Declaring variables within conditions
  • for loops
  • Infinite loops
  • Defining loop conditions
  • break and continue statements
  • Iterating with range
  • Nested loops
  • switch statements
  • Expression-based switches
  • Handling 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
  • 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 structs
  • Nil pointers
  • Appropriate use cases for pointers
  • Value semantics versus reference semantics
  • Go's memory management and garbage collection
  • Common pointer-related errors
  • Practical Exercise: Modify application data using pointers

10. Developing a Web Application in Go

  • Overview of Go's web development capabilities
  • Introduction to the net/http package
  • Creating an HTTP server
  • Processing HTTP requests and responses
  • HTTP methods
  • Request URLs and query parameters
  • HTTP headers
  • HTTP status codes
  • Fundamentals of routing
  • Creating handlers
  • Processing form data
  • Serving static files
  • Working with HTML templates
  • Template variables and control structures
  • Structuring web applications
  • Practical Exercise: 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 operations
  • Working with JSON
  • JSON encoding and decoding
  • Request validation
  • HTTP status codes
  • Error responses
  • Query parameters and path parameters
  • 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
  • The Go build process
  • go run
  • go build
  • go install
  • go test
  • Build flags
  • Environment-specific configuration
  • Building for various operating systems and architectures
  • Generating standalone binaries
  • Managing application configuration
  • Exercise: Compile the application for multiple platforms

13. File Handling and Web Interactions

  • Opening and closing files
  • Reading file contents
  • Writing to 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
  • Practical Exercise: Retrieve data from an external API and store it locally

14. Error Handling and Debugging

  • Go's error handling approach
  • Returning errors from functions
  • Checking for errors
  • Creating custom errors
  • Wrapping errors
  • Adding context to errors
  • errors.Is and errors.As
  • Panic and recovery mechanisms
  • Appropriate use of panic
  • Debugging common Go issues
  • Logging application activity
  • Using Go debugging tools
  • Exercise: Diagnose and resolve intentionally introduced application errors

15. Interfaces and Abstraction

  • Understanding interfaces
  • Implicit interface implementation
  • Defining interfaces
  • Interface values
  • Empty interfaces and any
  • Type assertions
  • Type switches
  • Pointer versus value implementations
  • Designing small interfaces
  • Dependency inversion
  • Using interfaces for testing
  • Reducing application coupling
  • Practical Exercise: Integrate interfaces into the sample web application

16. Packages and Project Structure

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

17. Concurrency with Goroutines

  • Understanding concurrency
  • Goroutines
  • Starting goroutines
  • Lightweight concurrent execution
  • Synchronization challenges
  • Shared state
  • Race conditions
  • Using sync.WaitGroup
  • Mutexes and read/write mutexes
  • Atomic operations
  • Practical Exercise: Convert sequential tasks 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
  • Practical Exercise: Build a concurrent worker system

19. Context and Request Management

  • The importance of contexts 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

  • The importance of automated testing
  • Writing unit tests
  • The testing package
  • Test functions
  • Test naming conventions
  • Table-driven tests
  • Testing error handling
  • Testing HTTP handlers
  • HTTP test servers
  • Test fixtures
  • Test coverage
  • Benchmarks
  • Example tests
  • Testing interfaces using mocks or fakes
  • Practical Exercise: 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 memory allocations
  • Handling 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
  • Safely handling 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 issues
  • Practical Exercise: Implement structured logging and health checks

24. Containerizing the Go Application

  • The benefits of using containers
  • Go applications and containerization
  • Writing a Dockerfile
  • Multi-stage builds
  • Creating a minimal runtime image
  • Managing configuration via environment variables
  • Container networking
  • Exposing application ports
  • Running the application in 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 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
  • Practical Exercise: Deploy the sample web application

26. Capstone: Complete Go Web Application

Participants will consolidate their knowledge by developing a complete application.

The project may 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
  • Maintaining code simplicity
  • Effective package design
  • Error-handling best practices
  • Interface design principles
  • Concurrency best practices
  • Testing strategies
  • Performance considerations
  • Maintainability and readability
  • Common mistakes made by novice 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

  • A solid understanding of general programming principles

Target Audience

  • Developers
 28 Hours

Testimonials (5)

Related Categories