Overview
This article explains how to use Redis with Go.
Starting Redis
For an explanation of Redis and how to start it using Docker, refer to this article.
Start Redis:
| |
Check the connection using redis-cli:
| |
If it returns PONG, the connection is successful.
Create a Go Project
Create a new Go project:
| |
Using Redis in Go
Here is a sample code that connects to Redis, writes, and reads data:
| |
Install the dependencies:
| |
Run the program:
| |
If you see the following output, everything is working correctly:
| |
Summary
This article explained how to use Redis with Go. When working with Redis in Go, use the go-redis package.
Related Articles
- How to Run Redis with Docker (how to start Redis)
- Setting Up a Go Development Environment on Mac and Running Hello World (Go environment setup)