Course Outline
1. Introduction to Go
- Introduction to Go (Golang)
- Origins and design principles of Go
- Application of Go in web and systems programming
- Primary features:
- Static typing
- Emphasis on simplicity and readability
- Rapid compilation
- Native support for concurrency
- Automatic memory management via garbage collection
- Ability to compile for multiple platforms
- Typical use cases for Go
- Strengths and constraints of the language
- Comparison with C/C++, JavaScript, Ruby, Python, and Java
- Overview of the Go ecosystem
- Introduction to the Go standard library
- Go modules and managing dependencies
- Structure of a Go application
- Practical exercise: Analyze and execute a basic Go program
2. Configuring the Go Development Environment
- Installation of Go
- Components of the Go toolchain
- Setting up environment variables
- Selecting an IDE or code editor
- Interacting with Go via the command line
- Establishing a Go workspace
- Standard Go project layout
- Starting a project using Go Modules
- Utilizing
go mod init - Handling dependencies with
go get - Updating and reviewing dependencies
- Standardizing code style with
gofmt - Executing programs using
go run - Compiling applications with
go build - Installing Go applications
- Compiling for cross-platform compatibility
- Practical exercise: Initialize and set up a Go project within a container
3. Go Variables, Constants, and Data Types
- Variable declaration
- Explicitly defined types versus inferred types
- Short-form variable declaration
- Constant definitions
- Zero values
- Variable scope and lifetime
- Basic data types:
- Integers
- Floats
- Complex numbers
- Booleans
- Strings
- Type casting
- Handling Unicode and UTF-8
- Differences between Runes and bytes
- Assigning multiple variables simultaneously
- Concepts of type safety
- Task: Develop a basic command-line tool for data processing
4. Operators and Expressions
- Arithmetic operations
- Comparison operators
- Logical operators
- Assignment operators
- Increment and decrement operators
- Precedence of operators
- Performing calculations with integers and floats
- Mitigating common type conversion errors
- Task: Code calculation and validation logic
5. Dates, Times, and Formatting
- Utilizing the
timepackage - Generating and adjusting dates
- Retrieving the current time
- Handling time zones and locations
- Interpreting date and time strings
- Formatting date and time output
- Calculating time differences
- Working with Unix timestamps
- Managing timeouts
- Task: Integrate timestamps and duration calculations into an application
6. Arrays, Slices, Maps, and Structs
Arrays
- Declaring arrays
- Initializing arrays
- Looping through arrays
- Multi-dimensional arrays
Slices
- Differences between slices and arrays
- Creating slices
- Adding elements
- Duplicating slices
- Understanding slice length and capacity
- Creating sub-slices
- Frequent issues with slices
Maps
- Instantiating maps
- Inserting and deleting entries
- Verifying key presence
- Iterating through maps
- Maps with complex data values
Structs
-
Defining structs
-
Struct members
-
Initializing structs
-
Nested structs
-
Anonymous structs
-
Methods associated with structs
-
JSON tags for structs
-
Practical exercise: Represent users, products, and application data using structs, slices, and maps
7. Conditional Logic and Loops
ifstatementselseandelse ifconstructs- Declaring variables inside conditions
forloops- Infinite loops
- Loop termination conditions
breakandcontinuestatements- Iteration using
range - Nested loops
switchstatements- Expression-based switches
- Handling multiple cases
- Default cases
- Type switches
- Task: Code validation and processing logic for an application
8. Functions
- Defining functions
- Function parameters
- Return values
- Multiple return values
- Named return values
- Variadic functions
- Anonymous functions
- Functions as values
- Closures
- Recursion
- Passing functions as arguments
- Functions that return errors
- Designing small, reusable functions
- Task: Refactor existing code into reusable functions
9. Pointers and Memory Concepts
- Definition of a pointer
- Address-of and dereference operators
- Pointers and function parameters
- Pointer receivers
- Pointers to structs
- Nil pointers
- When to utilize pointers
- Value vs. reference semantics
- Go memory management and garbage collection
- Frequent pointer errors
- Practical exercise: Modify application data using pointers
10. Building a Web Application with Go
- Overview of Go's web capabilities
- Introduction to the
net/httppackage - Setting up an HTTP server
- Handling HTTP requests and responses
- HTTP methods
- Request URLs and query parameters
- HTTP headers
- HTTP status codes
- Basics of routing
- Creating handlers
- Processing form data
- Serving static files
- Using HTML templates
- Template variables and control structures
- Architecting a web application
- Practical exercise: Develop a fundamental Go web server
11. Building a RESTful Web Service
- Fundamentals of REST architecture
- Designing API endpoints
- GET, POST, PUT, PATCH, and DELETE methods
- Working with JSON
- Encoding and decoding JSON
- Request validation
- HTTP status codes
- Error responses
- Query and path parameters
- Structuring API responses
- Separating handlers from business logic
- Practical exercise: Create a CRUD REST API
12. Go Runtime, Compilation, and Project Builds
- How the Go compiler works
- The Go build process
go rungo buildgo installgo test- Build flags
- Environment-specific settings
- Building for various OS and architectures
- Creating standalone binaries
- Managing application configuration
- Task: Compile the application for multiple platforms
13. Handling Files and Web Data
- Opening and closing files
- Reading files
- Writing to files
- Creating directories
- File metadata
- Buffered Input/Output
- 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: Fetch data from an external API and save it locally
14. Error Handling and Debugging
- Go's error handling paradigm
- Returning errors from functions
- Checking for errors
- Creating custom errors
- Wrapping errors
- Adding context to errors
errors.Isanderrors.As- Panic and recovery
- Appropriate use of
panic - Debugging common Go issues
- Logging application activity
- Utilizing Go debugging tools
- Task: Identify and resolve intentionally introduced application errors
15. Interfaces and Abstraction
- Definition of an interface
- Implicit interface implementation
- Defining interfaces
- Interface values
- Empty interfaces /
any - Type assertions
- Type switches
- Pointer vs. 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 Organization
- Creating packages
- Package naming standards
- Exported vs. 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
- Task: Refactor the application into separate packages
17. Concurrency with Goroutines
- Concept of concurrency
- Goroutines
- Starting goroutines
- Understanding lightweight concurrent execution
- Synchronization challenges
- Shared state
- Race conditions
- Using
sync.WaitGroup - Mutexes and read/write mutexes
- Atomic operations
- Practical exercise: Transform a sequential task into concurrent processing
18. Channels
- Understanding channels
- Sending and receiving values
- Buffered vs. 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: Develop a concurrent worker system
19. Context and Request Management
- 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
- Task: Implement request cancellation and timeouts in the web application
20. Testing Go Applications
- Significance of automated testing
- Writing unit tests
- The
testingpackage - Test functions
- Test naming standards
- Table-driven tests
- Testing errors
- Testing HTTP handlers
- HTTP test servers
- Test fixtures
- Test coverage
- Benchmarks
- Example 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 bottlenecks
- CPU vs. 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
- Task: 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
- Task: Review and secure 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
- Practical exercise: Add structured logging and health checks
24. Containerizing the Go Application
- Benefits of using 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
- 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 vs. vertical scaling
- Basic deployment troubleshooting
- Practical exercise: Deploy the sample web application
26. Capstone: Complete Go Web Application
Participants synthesize the learned concepts 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 standards
- 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 new Go developers
- Recommended approaches for continuing Go development
28. Conclusion
- Recap 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
- Basic understanding of general programming principles
Audience
- Developers
Custom Corporate Training
Training solutions designed exclusively for businesses.
- Customized Content: We adapt the syllabus and practical exercises to the real goals and needs of your project.
- Flexible Schedule: Dates and times adapted to your team's agenda.
- Format: Online (live), In-company (at your offices), or Hybrid.
Price per private group, online live training, starting from 6400 € + VAT*
Contact us for an exact quote and to hear our latest promotions
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.