
Harness go as a powerful backend language with built-in json serialization, deserialization, and testing. Scaffold a project from scratch, dockerize the application, and automate a ci/cd workflow with CircleCI.
Discover why Go excels for real world apps, offering blazing performance, a single main.go deployment, built-in testing, Json serialization, and uniform formatting for fast backend development.
build a real world pollen alert app that messages you daily with the day's expected pollen level and its historical average using the University of Vienna API endpoints.
Define daily allergy endpoints flow, parse json responses, format messages for Slack via webhooks, and automate tests, docker container management, and ci pipelines with configurable endpoints and cron settings.
Verify your go installation with go version and install from go.dev/doc/install. Install the go extension in Visual Studio Code, a linter, tester, debugger, and formatter, then scaffold the go project.
Scaffold the app by installing go and the Visual Studio Code Go extension, creating a project folder allergy cron, initializing the module with go mod init, and creating main.go.
Implement a daily 8 a.m. cron job in go using the robfig cron library, load the Vienna time zone, start the scheduler, and keep the main thread alive.
Develop a generic Go HTTP request utility using generics to handle allergy API calls and Slack messages, including query params, headers, and JSON unmarshalling.
Call the allergy api with a generic http request function, define types for hourly load and current chart data, parse json, compute the historical average, and format a slack message.
Create a Slack app with incoming webhooks, obtain the webhook URL, and implement a Go utility to post messages to Slack from real-world applications.
Complete main.go by combining hourly load data and current chart data into a single Slack message using daily and historical averages, and send it via the Slack message utility.
Update the cron to the next minute, run go run main.go, and verify the slack message with the pollen load is sent, while noting upcoming environment-based optimizations and testing.
Write Go tests for the allergy API and Slack message functions, place tests in a tests folder with _test.go files, and run go test -p 1 -v tests.
Dockerize the go application by creating a dockerfile and a docker compose file, building a single binary, and running it in a container with a restart policy and background mode.
Replace a running docker container with minimal downtime by rebuilding with no cache and using docker compose up --detach --force-recreate; not zero downtime, suitable for cron jobs.
Enhance Slack messages with color and emojis for real-time allergy data using a format allergy data function with a scaled load switch, env file, and CircleCI deployment to Docker Hub.
Move secrets and hardcoded values to an .env file, including API URL, Slack webhook, time zone, and cron schedule, and load them with a Go env package.
Create a complete ci/cd pipeline with CircleCI to build, test, and deploy a Docker image to Docker Hub, using a config.yaml with jobs, workflows, environment variables, and workspace persistence.
Conclude the go for real world applications course with final comments and access the PDF ebook and GitHub repository, where each lesson is organized by branch.
Go is a powerful backend language that is an asset to any developer's toolkit. It is extremely performant, a relatively easy language in terms of syntax, and has many valuable features like testing and JSON serialization and deserialization built in. In this practical, hands-on, step-by-step style course, we'll build a fully functioning Go application from complete scratch along these steps:
- Scaffolding the Go application and writing main.go
- Writing cron jobs in Go
- Writing a powerful generic HTTP function
- Using that HTTP function to call an API and serialize the response into Go object's using Go
- Use that HTTP function to POST messages to a Slack channel
- Write tests using Go's built in testing module
- Dockerize the application so that it can be run with docker compose
- Round off the course by crafting a complete CI/CD pipeline that first builds and tests our application, then Dockerizes and uploads the application to Docker Hub
- We'll see that once the Circle CI pipeline is setup, we can control the entire pipeline process through pushing to a git branch alone, and never have to manually do any sort of configuration or commands for our deploys
By the end of the course, you will have the confidence and know how to build Go applications from start to finish - including testing, Dockerizing, and deploying them!