url-shortener

command module
v0.0.0-...-a654bab Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 5 Imported by: 0

README

URL Shortener

Do you know bit.ly? Well... Basically the same thing

Setup the app

You can run the app with or without docker. Both instruction will be avaliable below

With Docker
Running the app

Run:

docker-compose up

Or, if you wanna docker running on the background

docker-compose up -d
Testing

With the app running, run:

docker exec url_shortener go test ./...

NOTE: To run tests, your local database should be empty. sorry, still working on that

Without docker
Setup
  1. You should create the database and make it avaliable for connection before running/testing the app;
  2. Create a .env file to be read by the app. You can do it running:
cp .env.sample .env
  1. Fill the env file (instruction in environment variables section).
Running the app

Run:

go run main.go
Testing

Run:

go test ./...

NOTE: To run tests, your local database should be empty. sorry, still working on that

Environment variables

DATABASE_URL

Url to connect with database.

Template: postgres://user:password@host:port/database_name

Example: postgres://postgres_user:password@localhost:5432/url_shortener

NOTE Remember to create the database before running the app.

GIN_MODE

Mode that your app is running. It can be:

  • debug: local environment for developing;
  • release: production environment;
  • test: test environment.
SHORTENED_URL_CHARS_NUMBER

Number of characters on the shortened URL path. Example:

SHORTENED_URL_CHARS_NUMBER=5
host.com/XXXXX


SHORTENED_URL_CHARS_NUMBER=10
host.com/XXXXXXXXXX

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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