Skip to content

Repository files navigation

go-gin-template

An opinionated template to spin up a Go web server using the Gin package.

Quickstart

Ensure you have Go 1.25 installed.

Install the relevant tools listed below:

go install github.com/a-h/templ/cmd/templ@latest
go install github.com/air-verse/air@latest

Ensure your $GOPATH is set correctly as specified here.

Refer to Makefile for package commands; i.e. make dev.

Refer to router.go for available routes.

Vite Integration

For building with Vite, run npm run dev in the frontend folder. Start the backend server with make dev. Open the url http://localhost:8081, for hot reloading; albeit the html templates will be slow.

Docker

docker build -t myapp:latest .

# Without swap (recommended for containers)
# Same as memory = no swap allowed
# Disable swapping to disk
docker run -d \
  --name myapp \
  --memory=64m \
  --memory-swap=64m \
  --memory-swappiness=0 \
  --cpus="0.5" \
  -p 8080:8080 \
  -p 6060:6060 \
  -e GIN_MODE=release \
  myapp:latest

Load Testing

cd ./cmd/loadtest/
./start.sh

# Evaluate the respective pprof output
go tool pprof -http=:8081 ./<metric>.pprof

Resources

About

A template to spin up a Go web server using the Gin package.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages