Skip to content

codestorm-official/go-gin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Gin

Simple starter project using Gin

Deploy on Railway

Features

  • Root endpoint: GET / → returns a welcome JSON message.
  • Health endpoint: GET /health → returns application status and uptime.
  • Status/ping endpoint: GET /status → returns HTTP 200 OK.
  • Middleware: Gin Logger and Recovery.
  • Graceful shutdown when receiving OS signals (CTRL+C, SIGTERM, etc).

Getting Started

Make sure Go is installed (recommended Go 1.22+).

cp .env.example .env   # create .env from the template
# open .env and adjust the PORT value, for example:
# PORT=8080
go mod tidy
go run main.go

By default the server runs at http://localhost:3000 (or according to the PORT value in .env).

Using .env

  • .env.example is the environment template:
    • Copy it to .env with the command above.
    • Change the PORT value in .env as needed (e.g. 8080, 5000, etc.).
  • The application will:
    • Load the .env file at startup.
    • Read the PORT variable.
    • If PORT is not set, it will fall back to 3000.

Endpoints

  • GET /

    • Example response:

      {
        "message": "Welcome to Go Gin Starter"
      }
  • GET /health

    • Example response:

      {
        "status": "ok",
        "uptime": "10s"
      }
  • GET /status

    • Response is HTTP 200 with an empty body.

About

A minimal Gin RESTful API.

Topics

Resources

Stars

Watchers

Forks

Contributors