No description
- Go 53.4%
- HTML 46.1%
- Dockerfile 0.5%
| templates | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| config.go | ||
| db.go | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| handlers_admin.go | ||
| handlers_auth.go | ||
| handlers_links.go | ||
| LICENSE | ||
| main.go | ||
| middleware.go | ||
| models.go | ||
| README.md | ||
| renderer.go | ||
ShortLink
A self-hosted link shortener with multi-user support, invite-based registration, and role hierarchy.
Features
- Short links:
yourdomain.com/slugredirects to any URL - Homepage: public page with a text box to look up short links
- Roles: admin → mod → user hierarchy
- Admin: full control — manage all links, users, roles, and invites
- Mod: manage all links, create user invites
- User: manage own links only
- Invite system: admins create mod/user invites, mods create user invites
- First-run setup: first user becomes admin automatically
- Click tracking: each redirect increments a counter
- No JavaScript frameworks: plain Go templates, minimal vanilla JS for copy buttons
Quick start
- Clone this repo
- Copy the example environment file and edit it:
cp .env.example .env
- Edit
.env:- Set
BASE_URLto your actual domain (e.g.https://go.example.com) - Set
SITE_NAMEto whatever you like - Change
DB_PASSandMARIADB_ROOT_PASSWORDto strong, unique passwords
- Set
- Run:
docker compose up -d --build
- Visit your domain — you'll be prompted to create the first admin account.
Environment variables
All configuration is done via the .env file (see .env.example for a template).
| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
HTTP listen port |
DB_HOST |
db |
MariaDB hostname |
DB_PORT |
3306 |
MariaDB port |
DB_USER |
shortlink |
MariaDB username |
DB_PASS |
(required) | MariaDB password |
DB_NAME |
shortlink |
MariaDB database name |
MARIADB_ROOT_PASSWORD |
(required) | MariaDB root password |
SITE_NAME |
ShortLink |
Displayed in nav and homepage |
BASE_URL |
http://localhost:8080 |
Public URL (for copy buttons) |
Role permissions
| Action | Admin | Mod | User |
|---|---|---|---|
| Create own links | ✓ | ✓ | ✓ |
| Delete own links | ✓ | ✓ | ✓ |
| View all links | ✓ | ✓ | ✗ |
| Delete any link | ✓ | ✓ | ✗ |
| Create user invites | ✓ | ✓ | ✗ |
| Create mod invites | ✓ | ✗ | ✗ |
| Change user roles | ✓ | ✗ | ✗ |
| Delete users | ✓ | ✗ | ✗ |
Reverse proxy (Caddy example)
go.example.com {
reverse_proxy localhost:8080
}
Licence
CC0 — public domain.