A simple REST API built with Golang, Gin framework, and SQLite. This API generates random user data and provides a health check endpoint.
/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")
/generate: Generates and returns a random user from the database.- SQLite database with migration and pre-seeded users.
- Logging support for API requests and errors.
- Go (>=1.18)
- Gin (>=v1.10.0)
- SQLite (>=v1.5.7)
Clone the repository and navigate to the project directory:
git clone https://gitlab.com/aminelch/go-user-generator.git
cd go-user-generatorInitialize and download dependencies:
go mod tidyBuild the API:
make buildRun the API:
make serveThe API will be available at http://localhost:8080.
GET /healthResponse:
{
"status": "ok",
"uptime": "2025-03-25T09:15:00Z",
"version": "2.3.0",
"hostname": "prod-server-42",
"timestamp": "2025-03-25T10:30:22Z"
}GET /generateResponse Example:
{
"id": 3,
"name": "John Doe",
"email": "john.doe@example.com",
"uuid": "a7983f8d-8d77-4bda-bd45-819d7e19290c"
}This project is licensed under the GNU General Public License v3.0.