Create the repo, Makefile, lint config and docker-compose

Create the backend module with the cmd/ and internal/ layout, a Makefile with lint, test, run, up and down targets, a golangci-lint config, and a docker-compose file for MySQL and Redis.

Objective

Set up the backend project in your clone of the public zomato-prep repository so future exercises have a consistent development environment. You will add the project automation, lint configuration, and local service definitions without writing any Go code.

By the end:

  • The backend has a Makefile with commands for linting, testing, running, and managing local services.
  • The project has a golangci-lint v2 configuration with explicitly selected linters and formatters.
  • Docker Compose can start MySQL 8.4 and Redis 7.
  • Both services report healthy status through their healthchecks.
  • The project commands run from backend/.

Deliverables

  • backend/Makefile: Add the project commands:

    • lint: Run golangci-lint run.
    • test: Run the course test runner using go run ./tools/zt test $(W).
    • unit: Run Go unit tests with the race detector.
    • run: Start the API using go run ./cmd/api.
    • up: Start Docker Compose services in the background.
    • down: Stop Docker Compose services.

    Declare all targets as .PHONY. The test target must allow an optional exercise selector: make test W=1B2 runs one exercise, while make test runs all exercises.

  • backend/.golangci.yml: Configure golangci-lint v2 with:

    • version: "2" and linters.default: none.
    • Enabled linters: errcheck, govet with shadow, ineffassign, staticcheck, unused, errorlint, and gosec, excluding G404.
    • Enabled formatters: gofumpt and goimports.
    • goimports local prefix: github.com/yashdagar/zomato-prep.
  • backend/docker-compose.yml: Define two services:

    • MySQL: Use mysql:8.4, read MYSQL_ROOT_PASSWORD from the environment with dev as the default, create the zomato database, publish port 3306, mount a named volume for persistent data, and configure a mysqladmin ping healthcheck using the same root password.
    • Redis: Use redis:7-alpine, publish port 6379, and configure a redis-cli ping healthcheck.

No Go source files are required in this exercise. The starter repository already contains the tests, the tools/zt test runner, and the Go module for module github.com/yashdagar/zomato-prep/backend. You will add cmd/ and internal/ directories as later exercises need them.

Requirements

Constraints

  • Work inside the backend/ directory. Run all commands in this exercise from there.

  • Use the pinned image versions mysql:8.4 and redis:7-alpine. Do not use latest.

  • Use healthchecks for both services so dependent tools can determine when they are ready.

  • Use a named Docker volume for MySQL data.

  • Use the same MYSQL_ROOT_PASSWORD variable for the MySQL service and its healthcheck.

  • Keep the Makefile recipe indentation as tabs, not spaces.

  • Declare every Makefile target as .PHONY.

  • Do not introduce credentials beyond the local development defaults. The default password dev is only for local development.

  • Do not write Go code or rewrite the provided test runner.

  • make lint requires golangci-lint v2 to be installed. Install it using Homebrew:

    bash
    brew install golangci-lint

    Alternatively, use the official golangci-lint installation script from its documentation.

  • Docker must be running before you execute the Compose commands.

Acceptance criteria

Run the following commands from backend/:

bash
go version
make up
docker compose ps
make lint
make test
make down

Each command has an expected result:

  • go version: Prints the installed Go version. The project uses Go 1.25, so use a compatible Go toolchain.
  • make up: Starts the MySQL and Redis containers in detached mode. Docker Compose reports that the services have been started.
  • docker compose ps: Shows both services running and their health status as healthy. If they are still starting, wait briefly and check again.
  • make lint: Runs golangci-lint v2 without a configuration error. There are no application Go packages to lint yet, so the command must not fail because of the empty project or the linter configuration.
  • make test: Runs the course test runner. It reports that the exercise steps have not been written yet. This is expected because this exercise creates the development environment, not the Go implementation.
  • make down: Stops and removes the Compose containers and network. The named MySQL volume remains available for the next make up.

The complete command sequence is:

bash
cd backend
go version
make up
docker compose ps
make lint
make test
make down

Run the commands in order. Do not run make lint or make test from the repository root.

Finished Exercise 1.3?

Project setup

3 items

  • 1.1The Go toolchain, modules and packagesnot completed
  • 1.2Makefile, golangci-lint and Docker Composenot completed
  • 1.3Create the repo, Makefile, lint config and docker-composenot completed

Go fundamentals

Up next · Module 2 · 5 items · about 2 h 30 min

Start module 2

Implementation

Run locally

Write the code in your editor inside zomato-prep, then work through this list.

  1. backend/go.mod declares the module github.com/yashdagar/zomato-prep/backend.
  2. make up starts MySQL and Redis and docker compose ps shows both healthy.
  3. make lint runs golangci-lint and exits cleanly on the empty project.
  4. make test runs go test ./... without errors.
  5. make down stops the containers.

Commands

terminal
cd backend && go version
terminal
cd backend && make up
terminal
cd backend && docker compose ps
terminal
cd backend && make lint

This exercise has no Go test. The commands above are the check: when each one shows what the list says, the exercise is done.