1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-25 22:21:49 +02:00

fix: adjust to some linter findings

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2024-02-05 13:46:12 +01:00
parent 02ec50c91d
commit e166806d1b
15 changed files with 112 additions and 42 deletions

View File

@@ -31,7 +31,7 @@ import (
)
type PostItem struct {
UserId uint `json:"userId"`
UserID uint `json:"userId"`
Id uint `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
@@ -41,7 +41,7 @@ type CatFact struct {
Fact string `json:"fact"`
}
func heterogeneousHttpRequests(count int) R.ReaderIOEither[[]T.Tuple2[PostItem, CatFact]] {
func heterogeneousHTTPRequests(count int) R.ReaderIOEither[[]T.Tuple2[PostItem, CatFact]] {
// prepare the http client
client := H.MakeClient(HTTP.DefaultClient)
// readSinglePost sends a GET request and parses the response as [PostItem]
@@ -64,7 +64,7 @@ func heterogeneousHttpRequests(count int) R.ReaderIOEither[[]T.Tuple2[PostItem,
)
}
func heterogeneousHttpRequestsIdiomatic(count int) ([]T.Tuple2[PostItem, CatFact], error) {
func heterogeneousHTTPRequestsIdiomatic(count int) ([]T.Tuple2[PostItem, CatFact], error) {
// prepare the http client
var result []T.Tuple2[PostItem, CatFact]
@@ -109,13 +109,13 @@ func BenchmarkHeterogeneousHttpRequests(b *testing.B) {
b.Run("functional", func(b *testing.B) {
for n := 0; n < b.N; n++ {
benchResults = heterogeneousHttpRequests(count)(context.Background())()
benchResults = heterogeneousHTTPRequests(count)(context.Background())()
}
})
b.Run("idiomatic", func(b *testing.B) {
for n := 0; n < b.N; n++ {
benchResults, _ = heterogeneousHttpRequestsIdiomatic(count)
benchResults, _ = heterogeneousHTTPRequestsIdiomatic(count)
}
})