Another Google-like Go short link service
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Ankit R Gadiya f9c5cb6f4e
cmd: addds open command
4 months ago
.github/workflows ci: updates main branch 7 months ago
cmd cmd: addds open command 4 months ago
internal server: handles auto-generating slugs 7 months ago
web web: add toggle for full urls 1 year ago
.gitignore Initial commit 8 years ago
Dockerfile all: uses go1.19 7 months ago
LICENSE major rewrite 1 year ago
README.md README: updates the README 1 year ago
go.mod cmd: addds open command 4 months ago
go.sum cmd: addds open command 4 months ago
justfile justfile: updates the name to shrt 1 year ago
main.go major rewrite 1 year ago

README.md

Shrt - A "go" short-link service

This is my fork of the kellegous/go server [Original Readme]

Differences

  • SQLite based backend
  • Uses Go's builtin embedding for static assets
  • Command-line interface for CRUD to the server as well as database directly

Installation

Shrt can directly be installed using the Go toolchain by running the following command.

go install argc.in/shrt@latest

The SQLite library mattn/go-sqlite3 supports different compilation strategies. By default, Go will try to compile the the SQLite library using the available C Compiler toolchain. On most linux systems that would be GLibC and GCC. This can be configured by build and link flags described here.

I personally prefer a statically linked binary that can be compiled using Musl and GCC. On Alpine Linux, it can be done by running the following command. On other Linux distributions, the CC variable can be configured to point to the Musl GCC binary. Also note the "-s -w" flags to strip off the symbol tables and debugging information to reduce the size.

CC=/usr/bin/x86_64-alpine-linux-musl-gcc go build --ldflags '-linkmode external -extldflags "-static" -s -w' -o shrt main.go

Alternatively, I also provide a Docker image through Github Packages with precompiled binary.

docker run -it \
    -v /path/to/data:/data \
    -p 8080:8080 \
    ghcr.io/ankitrgadiya/shrt@master serve --database /data/routes.db --addr 0.0.0.0:8080

Backup

SQLite provides backup API that is available through its command-line tool. This can be used to backup the database.

sqlite3 /data/routes.db ".backup /path/to/backup.db"

Alternatively, Shrt can be backed up remotely by using the Shrt command-line tool. It generates a tab-separated list of all the links configured. SQLite's command-line tool can import the TSV data directly for restoring.

shrt list --server https://SERVER_ADDRESS