Skip to content

zckkte/go-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go URL Shortener

A simple URL shortener service written in Go with SQLite for persistent storage.

Features

  • Shorten long URLs to easy-to-share short links
  • Redirect short links to their original URLs
  • Stores URLs with timestamps using SQLite
  • Built with Go's standard library

Getting Started

Installation

Clone the repo and run:

go mod tidy
go run main.go

The server will start on http://localhost:8080.

Usage

  • POST /shorten: Submit a JSON body with a URL to shorten.

    {
      "url": "https://example.com/very/long/url"
    }
  • GET /{short}: Redirects to the original URL.

Example

curl -X POST http://localhost:8080/shorten \
     -H "Content-Type: application/json" \
     -d '{"url":"https://example.com"}'

Response:

{
  "short_url": "http://localhost:8080/abc123"
}

About

a simple url shortener in golang and sqlite3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages