No description
  • Go 91.7%
  • Makefile 7.6%
  • Shell 0.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Manikandan Arjunan da4a654474
Update README.md
2025-12-29 16:46:52 +05:30
cli cli client for kv-db 2025-12-24 20:31:01 +05:30
log log package 2025-12-24 20:30:34 +05:30
go.mod Add files via upload 2025-12-24 20:29:43 +05:30
go.sum Add files via upload 2025-12-24 20:29:43 +05:30
init.sh Add files via upload 2025-12-24 20:29:43 +05:30
main.go Add files via upload 2025-12-24 20:29:43 +05:30
Makefile Add files via upload 2025-12-24 20:29:43 +05:30
README.md Update README.md 2025-12-29 16:46:52 +05:30

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 dependencies
  • make build - Build binaries
  • make clean - Clean build artifacts
  • make install - Install to system

Running

  1. Start the server:

    kv
    # Server started on port 6969
    
  2. 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.