Skip to content

Ivasan7/shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Intro to URL shorter

In this repo there is a GO(Golang) CLI application which can shorten a URL. Alternative to the Bit.ly or well known google services.

Basic operating principle

  • Get URL
    • Possible to get a standard websiste based on its URL and fethc it in text form or open in the browser
    • Fetch based on short URL, text or browser
  • Lengthen URL
    • Look up short URL original name
  • Shorten URL
    • Generate short URL and store it

User instructions

Assumes docker is installed on the host computer

  1. Clone the repo
  2. cd repo
  3. docker run . -t <image name>
  4. docker run -it <image name> /bin/bash
  5. (cd code/shortener) -> supposed to start up in this directory
  6. shortener -h
  7. On Linux systems the binary can be copied out and used natively so the "open in browser" functinality is available. (docker cp...)

Developer mode

  1. Repear steps 1-3
  2. docker run -it -v <abs/path/to/repo>:/code <image name> /bin/bash (pontentially volume mount can also be used, here binding mount due to simplicity of use)
  3. Run the tests
  • cd /code/shortener/dbman
  • go test dbman_test.go dbman.go
  1. Run the app: go run main.go <cmd> <flags>
  2. Build the app: go build -o <binary name> main.go

Improvement points

  1. More extensive tests
  2. Application level itegration/regressions tests
  3. Remove code duplication in some places
  4. Remove the necessity of storing the short URL-s
  • Long URL's can be found buy decoding the URI after fake.it/<URI> , which provides ID of the original URL to be fetched. This increases performance and consumes less resources.
  1. Cross compilation does not work correctly
  • for mac do env GOOS="darwin" go build -o <name> main.go, however the application is producing errors, likely incompatibility with the SQLlite3 driver.
  1. Extending the application to a server-client app could be easily done via (e.g.) gRPC. See: https://grpc.io/docs/tutorials/basic/go/ or HTTP server(REST) https://golang.org/doc/articles/wiki/

About

Simple Go application to shorten URLs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published