No description
  • Go 53.4%
  • HTML 46.1%
  • Dockerfile 0.5%
Find a file
Kalvin Carefour Johnny 7d3ebf6711
Create LICENSE
2026-03-27 23:59:30 +08:00
templates Fix mobile layout: equal-width form inputs and nav bar overflow 2026-03-22 03:43:10 +00:00
.dockerignore Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
.env.example Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
.gitignore Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
config.go Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
db.go First commit 2026-03-21 22:46:04 +08:00
docker-compose.yml Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
Dockerfile First commit 2026-03-21 22:46:04 +08:00
go.mod First commit 2026-03-21 22:46:04 +08:00
go.sum First commit 2026-03-21 22:46:04 +08:00
handlers_admin.go Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
handlers_auth.go Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
handlers_links.go Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
LICENSE Create LICENSE 2026-03-27 23:59:30 +08:00
main.go Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
middleware.go First commit 2026-03-21 22:46:04 +08:00
models.go Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00
README.md Update README.md 2026-03-27 23:45:11 +08:00
renderer.go Fix security vulnerabilities, bugs, and add .env configuration system 2026-03-21 14:53:24 +00:00

ShortLink

A self-hosted link shortener with multi-user support, invite-based registration, and role hierarchy.

CC0 1.0 Universal (CC0 1.0) Public Domain Dedication

AI Generated Badge

Features

  • Short links: yourdomain.com/slug redirects 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

  1. Clone this repo
  2. Copy the example environment file and edit it:
cp .env.example .env
  1. Edit .env:
    • Set BASE_URL to your actual domain (e.g. https://go.example.com)
    • Set SITE_NAME to whatever you like
    • Change DB_PASS and MARIADB_ROOT_PASSWORD to strong, unique passwords
  2. Run:
docker compose up -d --build
  1. 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.