Skip to content

Latest commit

 

History

History
106 lines (66 loc) · 1.2 KB

File metadata and controls

106 lines (66 loc) · 1.2 KB

Fibonacci API (Go)

A simple Go API to generate a Fibonacci sequence.

Features

  • Exposes an HTTP endpoint: /fibonacci?n=10
  • Includes logging with levels
  • Unit tests provided
  • Dockerized with a multi-stage build

Requirements

  • Go 1.24+
  • Docker (optional)

Getting Started

1. Clone the repository

git clone https://github.com/yourusername/fibonacci-api.git
cd fibonacci-api

API Usage

Sum

Request

GET /fibonacci?n=10

Response

[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

🔧 Prerequisites

  • Go (version 1.24)
  • Docker (optional, for containerized build)

🚀 Local Development

1. Initialize the module

go mod init go-fibonacci-api

2. Build Application

go build -o main .

3. Run Application

./main

4. Run Unit Tests

go test

Containerization

1. Build docker image

docker build -t <username>/go-fibonacci-api:1.0.0 .

2. Run docker image

docker run -p 8080:8080 <username>/go-fibonacci-api:1.0.0

3. Login into Docker

docker login

4. Push Docker Image

docker push <username>/go-fibonacci-api:1.0.0