Skip to content

Simple repository with a go application that exposes an api that calculates the fibonacci sequence for a number

License

Notifications You must be signed in to change notification settings

Prates23/go-fibonacci-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.20)
  • 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 .

2. Run docker image

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

3. Login into Docker

docker login

4. Push Docker Image

docker push <username>/go-fibonacci-api

About

Simple repository with a go application that exposes an api that calculates the fibonacci sequence for a number

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages