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.
- 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
Assumes docker is installed on the host computer
- Clone the repo
cd repo
docker run . -t <image name>
docker run -it <image name> /bin/bash
- (cd code/shortener) -> supposed to start up in this directory
shortener -h
- On Linux systems the binary can be copied out and used natively so the "open in browser" functinality is available. (docker cp...)
- Repear steps
1-3
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)- Run the tests
cd /code/shortener/dbman
go test dbman_test.go dbman.go
- Run the app:
go run main.go <cmd> <flags>
- Build the app:
go build -o <binary name> main.go
- More extensive tests
- Application level itegration/regressions tests
- Remove code duplication in some places
- 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.
- 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.
- 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/