shortly

command module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

shortly

This is a backend API built with Go. It is designed for scalability and simplicity.It serves as a URL shortener service with features like generating and retrieving shortened URLs.

Installation
  1. Clone the repository:

    git clone https://github.com/tin3ga/shortly.git
    cd shortly
    
  2. Install dependencies:

    go mod tidy
    
    
  3. Configure .env file:

    PORT=8088
    DATABASE_URL=postgresql://<user>:<pass>@<host>/<database>
    URL=http://localhost:8088/api/v1/
    
    
Configuration
  1. Add a GOOSE_DBSTRING in makefile

  2. Run make to set up migrations, dev dependencies etc.

    make help
    
    
Usage
  1. Run the application

    go run main.go
    
    
  2. Swagger Documentation Access API documentation at:

       http://localhost:8088/swagger/index.html
    
    
Deployment

Using Docker:

docker compose up

goose -dir ./sql/schema/ postgres postgresql://postgres:mypassword@localhost:5432/postgres?sslmode=disable up

For production, ensure you:

  • Use a secure .env file

  • Build the binary:

    go build -o app main.go
    
    
  • Deploy the binary or container to your server or cloud provider.

Testing

Using hey to test rate limiter

./hey -n 1000 -c 10 http://localhost:8088/ap1/v1/links/all

Using autocannon to test caching enable or disable caching in the .env file

 autocannon -d 20 -c 50 --renderStatusCodes http://localhost:8088/api/v1/links/all

License

This project is licensed under the MIT license.

© 2025 tin3ga

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal

Jump to

Keyboard shortcuts

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