3
4
Fork
You've already forked GoShort
0
  • Go 92.3%
  • CSS 5.7%
  • Dockerfile 1.2%
  • Shell 0.8%
Find a file
dependabot[bot] 66e95b649a
Bump docker/login-action from 3 to 4 ( #10 )
Bumps [docker/login-action](https://github.com/docker/login-action) from 3 to 4.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v3...v4)
---
updated-dependencies:
- dependency-name: docker/login-action
 dependency-version: '4'
 dependency-type: direct:production
 update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026年03月11日 22:51:34 +01:00
.github Bump docker/login-action from 3 to 4 ( #10 ) 2026年03月11日 22:51:34 +01:00
.vscode Replace deprecated function calls 2025年12月26日 20:41:33 +01:00
static Small design fix 2026年03月01日 09:24:59 +01:00
templates Small design fix 2026年03月01日 09:24:59 +01:00
.gitignore Some code improvements and updates 2021年08月10日 22:34:25 +02:00
database.go perf: hits aggregator + no-drop fallback; add concurrency & shutdown tests 2025年12月29日 21:43:36 +01:00
Dockerfile Go update, small design tweaks 2026年03月01日 09:17:30 +01:00
example-config.yaml Initial commit 2020年03月29日 10:48:43 +02:00
go.mod Go update, small design tweaks 2026年03月01日 09:17:30 +01:00
go.sum Go update, small design tweaks 2026年03月01日 09:17:30 +01:00
LICENSE Initial commit 2020年03月29日 10:48:43 +02:00
main.go Go update, small design tweaks 2026年03月01日 09:17:30 +01:00
main_test.go Fix test 2026年03月01日 09:43:24 +01:00
README.md Go update, small design tweaks 2026年03月01日 09:17:30 +01:00
templates.go Replace new.css with custom minimal CSS 2025年12月26日 21:40:24 +01:00
updateDeps.sh Updates and GitHub Actions 2024年01月02日 15:36:27 +01:00

GoShort

GoShort is a small, minimal URL shortener written in Go. It uses an embedded SQLite database and aims to be easy to run and operate.


  • Configuration: See example-config.yaml
  • Docker image: ghcr.io/jlelse/goshort:latest

Running (Docker - preferred)

The easiest and recommended way to run GoShort is via Docker. The official image is published to GitHub Packages.

Run the published image:

docker run -d \
 --name goshort \
 -p 8080:8080 \
 -v "$(pwd)/config:/app/config" \
 -v "$(pwd)/data:/app/data" \
 ghcr.io/jlelse/goshort:latest

If you prefer to build locally and run that image:

docker build -t goshort .
docker run -d \
 --name goshort \
 -p 8080:8080 \
 -v "$(pwd)/config:/app/config" \
 -v "$(pwd)/data:/app/data" \
 goshort

The service listens on port 8080 inside the container. Mount a config directory (containing config.yaml or config.json/config.toml) and a data directory for the SQLite database.


Building from source (when preferred) 🔧

Building from source is useful if you want to make changes, test locally, or don't want to use Docker.

Install Go (>= 1.26) then:

# build
go build -o goshort
# run tests
go test ./...
# run locally (ensure a config is available in ./config or ./config.yaml)
./goshort

Caddy reverse proxy (Docker Compose example) 🌐

Here's a minimal docker-compose.yml and Caddyfile that run GoShort behind Caddy (TLS + reverse proxy). Save the docker-compose.yml and Caddyfile next to your config and data directories.

docker-compose.yml:

services:goshort:image:ghcr.io/jlelse/goshort:latestrestart:unless-stoppedvolumes:- ./config:/app/config- ./data:/app/dataexpose:- "8080"networks:- webcaddy:image:caddy:2restart:unless-stoppedports:- "80:80"- "443:443"volumes:- ./Caddyfile:/etc/caddy/Caddyfile:ro- caddy_data:/data- caddy_config:/confignetworks:- webvolumes:caddy_data:caddy_config:networks:web:

Caddyfile (replace yourdomain.example with your domain):

yourdomain.example {
 reverse_proxy goshort:8080
}

Start the stack:

docker compose up -d

Caddy will handle TLS for you automatically and forward requests to the goshort service.


Configuration

Configuration can be done with a simple config.{json|yaml|toml} file in the working directory or a subdirectory config.

Required config values:

  • password: Password to create, update or delete short links
  • shortUrl: The short base URL (without trailing slash!)
  • defaultUrl: The default URL to which should be redirected when no slug is specified

Optional config values:

  • dbPath: Relative path where the database should be saved

See the example-config.yaml file for an example configuration.


Authentication

The preferred authentication method is Basic Authentication. If you try to create, modify or delete a short link, in the browser a popup will appear asking for username and password — enter just the password you configured. Alternatively you can append a URL query parameter password with your configured password.


Usage

You can either create, update or delete short links using a browser by visiting the endpoints below, or make HTTP POST requests.

  • Create a new short link: /s
    • url: URL to shorten
    • (optional) slug: the preferred slug
  • Update a short link: /u
    • slug: slug to update
    • new: new long URL
  • Delete a short link: /d
    • slug: slug to delete

License

GoShort is licensed under the MIT license. See the LICENSE file for details.