Skip to content
marcus-beauregardPublic

About

A small URL shortener in Go: POST a URL, GET a redirect.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

tinyurl

tinyurl

A URL shortener in Go that fits in one file.

CI License: GPL-2.0-or-later

Quick start

go run .

The server listens on :8080. Mint a short link:

curl -s -X POST localhost:8080 -d '{"url":"https://example.com"}'
# {"short":"http://localhost:8080/1a2b3c4d"}

Follow it — a 302, with the original URL in Location:

curl -i localhost:8080/1a2b3c4d

What it does

  • POST a JSON body with a url key, get {"short": "..."} back.
  • GET /<code> redirects, or answers 404.
  • Codes are 4 random bytes as hex — eight characters.
  • State is a map behind a sync.RWMutex, so concurrent POSTs cannot corrupt it.

Develop

go test ./...
gofmt -l .        # should print nothing
go vet ./...

Limits, stated plainly

Links live in memory (#7), there is no expiry (#8), no rate limit (#9), and the scheme is hardcoded to http (#6). Those are open issues, not surprises — pick one up.

Contributing

Humans and automated agents are both welcome. There is no CLA — every commit carries a DCO sign-off (git commit -s).

Start with a good first issue, or read CONTRIBUTING.md.

Licence

GPL-2.0-or-later — see LICENSE. Copyright (C) 2026 Marcus Beauregard.

About

A small URL shortener in Go: POST a URL, GET a redirect.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages