shrt

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 2 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
api
respond
Package respond is inspired by matryer/respond.
Package respond is inspired by matryer/respond.
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL