small changes

removed prometheus libs/usage
TODO: update README.md
This commit is contained in:
cihe 2024-12-05 15:57:26 +01:00
parent 5544bded9b
commit 5a67798892
4 changed files with 57 additions and 18 deletions

47
README.md Normal file
View file

@ -0,0 +1,47 @@
# High-performance Fibonacci numbers implementation in Go
[![Build Status](https://travis-ci.com/T-PWK/go-fibonacci.svg?branch=v1.0.0)](https://travis-ci.com/T-PWK/go-fibonacci)
[![GitHub issues](https://img.shields.io/github/issues/T-PWK/go-fibonacci.svg)](https://github.com/T-PWK/go-fibonacci/issues)
[![Go Report Card](https://goreportcard.com/badge/github.com/T-PWK/go-fibonacci)](https://goreportcard.com/report/github.com/T-PWK/go-fibonacci)
[![Coverage Status](https://coveralls.io/repos/github/T-PWK/go-fibonacci/badge.svg?branch=v1.0.0)](https://coveralls.io/github/T-PWK/go-fibonacci?branch=master)
[![GoDoc](https://godoc.org/github.com/T-PWK/go-fibonacci?status.svg)](https://godoc.org/github.com/T-PWK/go-fibonacci)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://blog.abelotech.com/mit-license/)
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:
```
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
```
Often, especially in modern usage, the sequence is extended by one more initial term:
```
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
```
This implementation has two methods: `Fibonacci` and `FibonacciBig`.
The `Fibonacci` function is more efficient, however, it returns correct numbers between 0 and 93 (inclusive). The `FibonacciBig` function, on the other hand, is less efficient but returns practically any Fibonacci number.
Example:
```go
package main
import (
"fmt"
"github.com/t-pwk/go-fibonacci"
)
func main() {
fmt.Println("20: ", fib.Fibonacci(20))
fmt.Println("200: ", fib.FibonacciBig(200))
}
```
And the output is
```
20: 6765
200: 280571172992510140037611932413038677189525
```

BIN
cmd/main

Binary file not shown.

18
go.mod
View file

@ -2,17 +2,11 @@ module apps
go 1.22.2
require (
github.com/gin-gonic/gin v1.10.0
github.com/prometheus/client_golang v1.20.5
)
require github.com/gin-gonic/gin v1.10.0
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.12.5 // indirect
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chenjiandongx/ginprom v0.0.0-20210617023641-6c809602c38a // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
@ -21,19 +15,16 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.23.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.12.0 // indirect
@ -42,5 +33,6 @@ require (
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View file

@ -5,20 +5,20 @@ import (
"fmt"
"net/http"
"github.com/chenjiandongx/ginprom"
//"github.com/chenjiandongx/ginprom"
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp"
//"github.com/prometheus/client_golang/prometheus/promhttp"
)
func StartServer() error {
r := gin.Default()
r.Use(ginprom.PromMiddleware(nil))
//r.Use(ginprom.PromMiddleware(nil))
r.GET("/fibonacci", CalculateFibonacci)
r.GET("/metrics", gin.WrapH(promhttp.Handler()))
//r.GET("/metrics", gin.WrapH(promhttp.Handler()))
return r.Run() // listen and serve on 0.0.0.0:8080
return r.Run(":9090")
}
func CalculateFibonacci(c *gin.Context) {