Skip to content

Commit 264a054

Browse files
author
Antoine Gelloz
committed
fix: lint
1 parent 10996f2 commit 264a054

File tree

5 files changed

+18
-29
lines changed

5 files changed

+18
-29
lines changed

Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ tasks:
1212

1313
lint:
1414
cmds:
15-
- golangci-lint -v run
15+
- golangci-lint -v run --fix

cmd/server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ import (
44
"context"
55
"crypto/tls"
66
"fmt"
7-
"github.com/gorilla/handlers"
8-
"github.com/numary/search/pkg/searchengine"
9-
"github.com/numary/search/pkg/searchhttp"
10-
"github.com/opensearch-project/opensearch-go"
11-
"go.opentelemetry.io/otel/trace"
127
"net/http"
138
"os"
149
"strings"
1510

11+
"github.com/gorilla/handlers"
1612
"github.com/gorilla/mux"
1713
"github.com/numary/go-libs/oauth2/oauth2introspect"
1814
"github.com/numary/go-libs/sharedauth"
1915
"github.com/numary/go-libs/sharedlogging"
2016
"github.com/numary/go-libs/sharedotlp/sharedotlptraces"
17+
"github.com/numary/search/pkg/searchengine"
18+
"github.com/numary/search/pkg/searchhttp"
19+
"github.com/opensearch-project/opensearch-go"
2120
"github.com/sirupsen/logrus"
2221
"github.com/spf13/cobra"
2322
"github.com/spf13/viper"
2423
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
24+
"go.opentelemetry.io/otel/trace"
2525
"go.uber.org/fx"
2626
)
2727

pkg/searchengine/main_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,6 @@ func insertAccount(t *testing.T, ledgerName, id string, when time.Time, payload
112112
})
113113
}
114114

115-
func insertPayment(t *testing.T, id string, when time.Time, payload interface{}) {
116-
insertESDocument(t, id, "PAYMENT",
117-
map[string]interface{}{
118-
"kind": "PAYMENT",
119-
"when": when,
120-
"data": payload,
121-
})
122-
}
123-
124115
func TestSearchEngine(t *testing.T) {
125116

126117
if testing.Verbose() {

pkg/searchhttp/cursor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type cursorTokenInfo struct {
2828
SearchAfter []interface{} `json:"searchAfter"`
2929
Ledgers []string `json:"ledgers"`
3030
Size uint64 `json:"size"`
31-
TermPolicy string `json:"termPolicy""`
31+
TermPolicy string `json:"termPolicy"`
3232
Reverse bool `json:"reverse"`
3333
Terms []string `json:"terms"`
3434
}

pkg/searchhttp/http.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@ import (
1818
"github.com/tidwall/gjson"
1919
)
2020

21-
func HealthHandler() http.HandlerFunc {
22-
return func(w http.ResponseWriter, r *http.Request) {
23-
w.WriteHeader(http.StatusOK)
24-
}
25-
}
26-
2721
func resolveQuery(r *http.Request) (*cursorTokenInfo, interface{}, error) {
28-
2922
var (
3023
target string
3124
cursorToken string
3225
info *cursorTokenInfo
3326
)
27+
3428
if r.ContentLength > 0 {
3529
type resolveQuery struct {
3630
Target string `json:"target"`
@@ -127,6 +121,7 @@ func resolveQuery(r *http.Request) (*cursorTokenInfo, interface{}, error) {
127121
}
128122
}
129123
}
124+
130125
return info, searchQuery, nil
131126
}
132127

@@ -138,7 +133,10 @@ func Handler(engine searchengine.Engine) http.HandlerFunc {
138133
return
139134
}
140135

141-
r.ParseForm()
136+
if err := r.ParseForm(); err != nil {
137+
http.Error(w, err.Error(), http.StatusBadRequest)
138+
return
139+
}
142140

143141
cursor, searchQuery, err := resolveQuery(r)
144142
if err != nil {
@@ -206,15 +204,15 @@ func Handler(engine searchengine.Engine) http.HandlerFunc {
206204
TermPolicy: qq.TermPolicy,
207205
Terms: qq.Terms,
208206
}
209-
for _, sort := range qq.Sort {
210-
value := gjson.Get(string(item), sort.Key)
207+
for _, s := range qq.Sort {
208+
value := gjson.Get(string(item), s.Key)
211209
nextNti.SearchAfter = append(nextNti.SearchAfter, value.Value())
212210
}
213211
next = EncodePaginationToken(*nextNti)
214212
}
215213
previous := ""
216214
if cursor != nil && (!reverse || (reverse && hasMore)) {
217-
sort := make([]searchengine.Sort, 0)
215+
var sort []searchengine.Sort
218216
if cursor.Reverse {
219217
sort = cursor.Sort
220218
} else {
@@ -230,8 +228,8 @@ func Handler(engine searchengine.Engine) http.HandlerFunc {
230228
Terms: qq.Terms,
231229
}
232230
firstItem := items[0]
233-
for _, sort := range qq.Sort {
234-
value := gjson.Get(string(firstItem), sort.Key)
231+
for _, s := range qq.Sort {
232+
value := gjson.Get(string(firstItem), s.Key)
235233
previousNti.SearchAfter = append(previousNti.SearchAfter, value.Value())
236234
}
237235
previous = EncodePaginationToken(*previousNti)

0 commit comments

Comments
 (0)