This repository contains a startup build for a web application using Golang. The architecture is well-structured, making it easy to understand and extend. The application utilizes several Golang packages to manage configuration, handle routes, perform template rendering, and manage sessions.
Main Packages and Technologies Used
net/http
for handling HTTP requests and responses.github.com/alexedwards/scs/v2
for session management.github.com/go-chi/chi
for routing.html/template
for HTML templating.github.com/justinas/nosurf
for CSRF protection.
main.go
: This is the entry point of the application. It sets up the server, session manager, and loads the templates.middleware.go
: Contains middleware functions like CSRF protection and session management.routes.go
: Specifies the application's routes and corresponding handler functions.pkg/config/config.go
: Holds the application's configuration settings.pkg/handlers/handlers.go
: Contains the handler functions that deal with HTTP requests and responses.pkg/models/templatedata.go
: Defines the structure of data to be passed into templates.pkg/render/render.go
: Handles rendering of HTML templates.
- Clone this repository: git clone
https://github.com/GiorgiMakharadze/web-application-starter-golang.git
- Navigate to the project directory.
- Install dependencies:
go get ./...
html/template
for HTML templates- To run the application, execute:
go run cmd/web/*.go