README.md
March 12, 2026 ยท View on GitHub
This is a Redis starter template for Go:
Requirements
- make
- go>=1.26.1
- docker
- Optional
Getting started
Copy and edit the .env file:
cp .env.example .env
Your .env file should contain the connection string you copied from Redis Cloud.
The additional settings are optional:
APP_ENVdefaults todevelopmentand also acceptstestorproductionLOG_LEVELdefaults toinfoLOG_STREAM_KEYdefaults tologs
If APP_ENV is unset, NODE_ENV is accepted as a fallback alias.
Your .env.docker file will look similar to .env, but should use the appropriate docker internal URLs. Here is
an example:
HOST_PORT=8081
REDIS_URL="redis://redis:6379"
Next, spin up docker containers:
make docker
You should have a server running on http://localhost:<host-port> where HOST_PORT comes from .env.docker (default is 8081). The app still listens on the internal PORT value (default 8080). You can test the following routes:
GET /api/todos- Gets all todosGET /api/todos/:id- Gets a todo by IDGET /api/todos/search?[name=<name>]&[status=<status>]- Search for todos by name and/or statusPOST /api/todos- Create a todo with{ "name": "Sample todo" }PATCH /api/todos/:id- Update todo by ID with{ "status": "todo|in progress|complete" }DELETE /api/todos/:id- Delete a todo by ID
Running tests
There are unit and Docker-backed integration tests that can be run with the following command:
make test
These tests setup and teardown on their own with Testcontainers. If you want to skip the Docker-backed coverage, run:
make test-short
Running locally outside docker
To run the development server outside of docker:
make dev
Other Scripts
Run make to see the list of available commands. Application and request logs are written to stdout and also appended to the Redis stream named by LOG_STREAM_KEY.
Connecting to Redis Cloud
If you don't yet have a database setup in Redis Cloud get started here for free.
To connect to a Redis Cloud database, log into the console and find the following:
- The
public endpoint(looks likeredis-#####.c###.us-east-1-#.ec2.redns.redis-cloud.com:#####) - Your
username(defaultis the default username, otherwise find the one you setup) - Your
password(either setup through Data Access Control, or available in theSecuritysection of the database page.
Combine the above values into a connection string and put it in your .env and .env.docker accordingly. It should
look something like the following:
REDIS_URL="redis://default:<password>@redis-#####.c###.us-west-2-#.ec2.redns.redis-cloud.com:#####"
Run the tests to verify that you are connected properly.
Learn more
To learn more about Redis, take a look at the following resources:
- Redis Documentation - learn about Redis products, features, and commands.
- Learn Redis - read tutorials, quick starts, and how-to guides for Redis.
- Redis Demo Center - watch short, technical videos about Redis products and features.