No description
- Go 91.7%
- Makefile 7.6%
- Shell 0.7%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| cli | ||
| log | ||
| go.mod | ||
| go.sum | ||
| init.sh | ||
| main.go | ||
| Makefile | ||
| README.md | ||
Go KV [Generated by AI]
A simple key-value database written in Go with HTTP API and CLI client, developed to get familiar with golang language.
Features
- In-memory key-value storage
- HTTP REST API server
- Command-line client
- Thread-safe operations
- Request logging with UUID tracking
- CRUD operations (Create, Read, Update)
Architecture
- Server: HTTP API server running on port 6969
- Client: CLI tool for interacting with the database
- Storage: In-memory map with concurrent access protection
API Endpoints
Set a key-value pair
POST /set
Content-Type: application/json
{
"key": "string",
"value": "string"
}
Get a value by key
GET /get?key=<key>
Update an existing key-value pair
PUT /update
Content-Type: application/json
{
"key": "string",
"value": "string"
}
CLI Usage [Supported only on linux/mac]
Build the project: This will install kv && kv-cli commands on your system
make install
Run the server:
kv
Use the CLI client:
kv-cli help
CLI Commands
-
Set a key:
kv-cli set <key> <value>kv-cli set userId 123 -
Get a value:
kv-cli get <key>kv-cli get userId -
Update a key:
kv-cli update <key> <value>kv-cli update userId 456 -
Show help:
kv-cli help
Installation
From source
git clone <repository-url>
cd kv-db
make init
make install
This will install the binaries to $HOME/.local/bin by default.
Development
Dependencies
- Go 1.24.1+
Build commands
make init- Initialize dependenciesmake build- Build binariesmake clean- Clean build artifactsmake install- Install to system
Running
-
Start the server:
kv # Server started on port 6969 -
Use the CLI client in another terminal:
kv-cli set name "John Doe" kv-cli get name kv-cli update name "Jane Doe"
Error Handling
- 422 Unprocessable Entity: Missing or invalid key/value
- 400 Bad Request: Duplicate key on SET operation
- 404 Not Found: Key not found on GET/UPDATE operations
Logging
The server includes request logging with unique UUID tracking for each server instance.