/go-user-generator

This repository is a mirror of the original project hosted on Gitlab

Primary LanguageGoGNU Affero General Public License v3.0AGPL-3.0

go-user-generator API

Latest Release pipeline status License GO version Build Status Test Status Lint Status Lint Status

A simple REST API built with Golang, Gin framework, and SQLite. This API generates random user data and provides a health check endpoint.

Features

  1. /health: Returns API status information including:
  • Current version (from APP_VERSION or default)
  • Server uptime (start timestamp in ISO 8601)
  • Hostname of the server
  • Current timestamp
  • Status indicator ("ok")
  1. /generate: Generates and returns a random user from the database.
  2. SQLite database with migration and pre-seeded users.
  3. Logging support for API requests and errors.

Prerequisites

  • Go (>=1.18)
  • Gin (>=v1.10.0)
  • SQLite (>=v1.5.7)

Installation

Clone the repository and navigate to the project directory:

git clone https://gitlab.com/aminelch/go-user-generator.git
cd go-user-generator

Initialize and download dependencies:

go mod tidy

Running the API

Build the API:

make build

Run the API:

make serve

The API will be available at http://localhost:8080.

API Endpoints

Health Check

GET /health

Response:

{
  "status": "ok",
  "uptime": "2025-03-25T09:15:00Z",
  "version": "2.3.0",
  "hostname": "prod-server-42",
  "timestamp": "2025-03-25T10:30:22Z"
}

Generate Random User

GET /generate

Response Example:

{
  "id": 3,
  "name": "John Doe",
  "email": "john.doe@example.com",
  "uuid": "a7983f8d-8d77-4bda-bd45-819d7e19290c"
}

License

This project is licensed under the GNU General Public License v3.0.