GoShort is a minimal and fast URL shortener service written in Go using the Gin framework and Redis for storage.
Local interface captured against the Go API with a temporary, in-memory Redis-compatible test server. The short link shown is disposable; this is not a hosted production demo.
- Shorten long URLs
- Custom short codes - Choose your own memorable short code (3-20 alphanumeric characters)
- Redirect short URLs to original ones
- Track how many times a short URL was clicked
- Docker + Docker Compose ready
- Go 1.24.5+
- Gin Web Framework
- Redis (as key-value store)
- Docker + Docker Compose
git clone https://github.com/AhmetTK4/goshort.git
cd goshortdocker compose up --build- API runs at: http://localhost:8080
- Redis is reachable by the API at
redis:6379inside Compose; its port is not published to the host.
In another terminal, with Node.js 22 and npm installed:
cd frontend
npm ci
npm startOpen http://localhost:3000, paste an HTTP(S) URL, and click Shorten. Open the resulting link to trigger a redirect. The interface fetches the click count when shortening; submit the same original URL again to refresh its count. Compose starts the API and Redis, not the frontend.
REDIS_ADDR: API's Redis address; defaults tolocalhost:6379outside Docker. Compose setsredis:6379.BASE_URL: externally reachable API URL used to create short links; defaults tohttp://localhost:8080.REACT_APP_API_BASE_URL: frontend API URL, read when starting/building the frontend; defaults tohttp://localhost:8080.
The API currently permits browser requests from http://localhost:3000. Configure an explicit allowed origin before hosting the frontend elsewhere. Only absolute HTTP(S) URLs without embedded credentials are accepted.
go test ./...
go vet ./...
cd frontend
npm ci
npm test -- --watchAll=false
npm run buildAPI tests cover URL creation, redirects, click counts, invalid URLs, and unknown codes with an in-memory Redis-compatible test server. Frontend tests cover empty input, successful shortening, and API failures. See CONTRIBUTING.md.
This is a local learning project. Links expire after one hour; click counters currently do not share that expiry. Redis data is not configured for durable storage. Rate limiting, abuse prevention, collision handling, and hardened deployment are not implemented. Do not expose the demo as a public URL-shortening service without addressing those concerns. No performance benchmark is claimed.
Shortens a long URL.
Request:
{
"url": "https://example.com/very/long/url",
"custom_code": "mycode"
}The custom_code parameter is optional. If provided, it must be 3-20 alphanumeric characters. If omitted, a random 6-character code is generated.
Response:
{
"short_url": "http://localhost:8080/g/mycode"
}Redirects to original URL.
Example:
http://localhost:8080/g/AbC123
Returns how many times the short URL was clicked.
Response:
{
"short_code": "AbC123",
"clicks": "5"
}# Shorten with auto-generated code
curl -X POST http://localhost:8080/api/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://openai.com"}'
# Shorten with custom code
curl -X POST http://localhost:8080/api/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://openai.com", "custom_code": "openai"}'.
├── main.go
├── Dockerfile
├── docker-compose.yml
├── go.mod / go.sum
├── /service
└── /storage
Made by Ahmet Temel Kundupoğlu - https://github.com/AhmetTK4
MIT — Copyright (c) 2026 Ahmet Temel Kundupoğlu.
