A lightning-fast URL shortening service built with Go and Redis, designed for high performance and reliability.
- Fast URL Shortening: Efficient Base62 encoding for short, memorable URLs
- Redis Backend: High-performance storage and retrieval
- RESTful API: Clean and intuitive API endpoints
- Analytics: Track creation time, last access, and usage count
- Concurrent Processing: Handle multiple requests efficiently
- Production Ready: Includes tests, CI/CD, and comprehensive error handling
- Go - Core programming language
- Redis - Primary database
- godotenv - Environment configuration
- go-redis - Redis client for Go
- Go 1.23.2 or higher
- Redis server
- Git
-
Clone the repository
git clone https://github.com/SartajBhuvaji/goURLShortnet.git cd goURLShortner
-
Install dependencies
go mod download
-
Configure environment Create a
.env
file in the root directory:REDIS_HOST="REDIS_HOST" REDIS_PASSWORD="REDIS_PASSWORD" REDIS_DB=0
-
Start the server
go run main.go
Server starts on
http://localhost:8080
-
API Endpoints
POST /shorten Content-Type: application/json { "url": "https://www.example.com/very/long/url/that/needs/shortening" }
Response:
{ "short_url": "www.goURLShortner/abc123" }
GET /redirect?url=abc123
Response:
{ "long_url": "https://www.example.com/very/long/url/that/needs/shortening" }
Run the test suite:
go test ./tests -v