This is a basic URL shortener application built in Go to learn the basics of Go. It demonstrates the use of Go's net/http
package for handling HTTP requests and sqlite
as a lightweight database for storing URLs. The application allows users to shorten URLs and redirect to the original URLs using the shortened ones.
- Shorten long URLs to short codes
- Redirect to the original URL using the short code
- Simple web interface for URL shortening
- Persistent storage using SQLite
- Go installed
-
Clone the repository:
git clone https://github.com/programordie2/go-url-shortener.git cd go-url-shortener
-
Install dependencies:
go mod tidy
-
Run the application:
go run main.go
-
Open your web browser and navigate to
http://localhost:8080
to access the URL shortener.
main.go
: The main server implementation using Go'snet/http
package.static/
: Contains static files for the web interface.
- Enter the URL you want to shorten in the input box on the web page.
- Click the "Shorten" button.
- The shortened URL will be displayed, which you can use to redirect to the original URL.
This project is licensed under the MIT License.