Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit e6175c1

Browse files
address remaining linter warnings
1 parent a4f6298 commit e6175c1

File tree

14 files changed

+75
-76
lines changed

14 files changed

+75
-76
lines changed

runtime/collections/vector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func createIndexObject(searchMethod manifest.SearchMethodInfo, searchMethodName
7474
vectorIndex.Type = sequential.SequentialVectorIndexType
7575
vectorIndex.VectorIndex = sequential.NewSequentialVectorIndex(searchMethodName, searchMethod.Embedder)
7676
default:
77-
return nil, fmt.Errorf("Unknown index type: %s", searchMethod.Index.Type)
77+
return nil, fmt.Errorf("unknown index type: %s", searchMethod.Index.Type)
7878
}
7979

8080
return vectorIndex, nil

runtime/graphql/graphql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ func handleGraphQLRequest(w http.ResponseWriter, r *http.Request) {
9191
logger.Warn(ctx).Msg(msg)
9292
utils.WriteJsonContentHeader(w)
9393
if ok, _ := gqlRequest.IsIntrospectionQuery(); ok {
94-
_, _ = w.Write([]byte(`{"data":{"__schema":{"types":[]}}}`))
94+
fmt.Fprint(w, `{"data":{"__schema":{"types":[]}}}`)
9595
} else {
96-
_, _ = w.Write([]byte(fmt.Sprintf(`{"errors":[{"message":"%s"}]}`, msg)))
96+
fmt.Fprintf(w, `{"errors":[{"message":"%s"}]}`, msg)
9797
}
9898
return
9999
}

runtime/languages/assemblyscript/tests/special_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ func GetRuntimeTypeInfo(mod wasm.Module, md *metadata.Metadata) (string, error)
4848
gbl := mod.ExportedGlobal("__rtti_base")
4949
offset := uint32(gbl.Get())
5050
sb.WriteString("\nRuntime type information:\n")
51-
sb.WriteString(fmt.Sprintf("base: 0x%x\n", offset))
51+
fmt.Fprintf(sb, "base: 0x%x\n", offset)
5252

5353
len, ok := mod.Memory().ReadUint32Le(offset)
5454
offset += 4
5555
if !ok {
5656
return "", fmt.Errorf("failed to read length")
5757
}
58-
sb.WriteString(fmt.Sprintf("length: %v\n", len))
58+
fmt.Fprintf(sb, "length: %v\n", len)
5959

6060
sb.WriteString("\n")
6161

@@ -81,7 +81,7 @@ func GetRuntimeTypeInfo(mod wasm.Module, md *metadata.Metadata) (string, error)
8181
}
8282
}
8383

84-
sb.WriteString(fmt.Sprintf("%v: %s\n", i, typeName))
84+
fmt.Fprintf(sb, "%v: %s\n", i, typeName)
8585

8686
f, ok := mod.Memory().ReadUint32Le(offset)
8787
offset += 4

runtime/middleware/jwt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func Shutdown() {
7878
func HandleJWT(next http.Handler) http.Handler {
7979
var jwtParser = jwt.NewParser()
8080
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
81-
var ctx context.Context = r.Context()
81+
ctx := r.Context()
8282
tokenStr := r.Header.Get("Authorization")
8383
if tokenStr != "" {
8484
if s, found := strings.CutPrefix(tokenStr, "Bearer "); found {

runtime/models/hypermode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func getHypermodeModelEndpointUrl(model *manifest.ModelInfo) (string, error) {
3636
if _hypermodeModelHost == "" {
3737
_hypermodeModelHost = os.Getenv("HYPERMODE_MODEL_HOST")
3838
if _hypermodeModelHost == "" {
39-
return "", fmt.Errorf("Hypermode hosted models are not available in this environment")
39+
return "", fmt.Errorf("hypermode hosted models are not available in this environment")
4040
}
4141
}
4242
endpoint := fmt.Sprintf("http://%s.%s/%[1]s:predict", strings.ToLower(model.Name), _hypermodeModelHost)

sdk/go/pkg/collections/collections.go

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ func WithNamespace(namespace string) NamespaceOption {
8888

8989
func UpsertBatch(collection string, keys []string, texts []string, labelsArr [][]string, opts ...NamespaceOption) (*CollectionMutationResult, error) {
9090
if collection == "" {
91-
return nil, fmt.Errorf("Collection name is required")
91+
return nil, fmt.Errorf("collection name is required")
9292
}
9393

9494
if len(texts) == 0 {
95-
return nil, fmt.Errorf("Texts is empty")
95+
return nil, fmt.Errorf("texts is empty")
9696
}
9797

9898
nsOpts := &NamespaceOptions{
@@ -114,15 +114,15 @@ func UpsertBatch(collection string, keys []string, texts []string, labelsArr [][
114114
result := hostUpsert(&collection, &nsOpts.namespace, &keys, &texts, &labelsArr)
115115

116116
if result == nil {
117-
return nil, fmt.Errorf("Failed to upsert")
117+
return nil, fmt.Errorf("failed to upsert")
118118
}
119119

120120
return result, nil
121121
}
122122

123123
func Upsert(collection string, key *string, text string, labels []string, opts ...NamespaceOption) (*CollectionMutationResult, error) {
124124
if collection == "" {
125-
return nil, fmt.Errorf("Collection name is required")
125+
return nil, fmt.Errorf("collection name is required")
126126
}
127127

128128
keyArr := []string{}
@@ -138,7 +138,7 @@ func Upsert(collection string, key *string, text string, labels []string, opts .
138138
}
139139

140140
if text == "" {
141-
return nil, fmt.Errorf("Text is required")
141+
return nil, fmt.Errorf("text is required")
142142
}
143143

144144
nsOpts := &NamespaceOptions{
@@ -152,19 +152,19 @@ func Upsert(collection string, key *string, text string, labels []string, opts .
152152
result := hostUpsert(&collection, &nsOpts.namespace, &keyArr, &[]string{text}, &labelsArr)
153153

154154
if result == nil {
155-
return nil, fmt.Errorf("Failed to upsert")
155+
return nil, fmt.Errorf("failed to upsert")
156156
}
157157

158158
return result, nil
159159
}
160160

161161
func Remove(collection, key string, opts ...NamespaceOption) (*CollectionMutationResult, error) {
162162
if collection == "" {
163-
return nil, fmt.Errorf("Collection name is required")
163+
return nil, fmt.Errorf("collection name is required")
164164
}
165165

166166
if key == "" {
167-
return nil, fmt.Errorf("Key is required")
167+
return nil, fmt.Errorf("key is required")
168168
}
169169

170170
nsOpts := &NamespaceOptions{
@@ -178,7 +178,7 @@ func Remove(collection, key string, opts ...NamespaceOption) (*CollectionMutatio
178178
result := hostDelete(&collection, &nsOpts.namespace, &key)
179179

180180
if result == nil {
181-
return nil, fmt.Errorf("Failed to delete")
181+
return nil, fmt.Errorf("failed to delete")
182182
}
183183

184184
return result, nil
@@ -212,15 +212,15 @@ func WithReturnText(returnText bool) SearchOption {
212212

213213
func Search(collection, searchMethod, text string, opts ...SearchOption) (*CollectionSearchResult, error) {
214214
if collection == "" {
215-
return nil, fmt.Errorf("Collection name is required")
215+
return nil, fmt.Errorf("collection name is required")
216216
}
217217

218218
if searchMethod == "" {
219-
return nil, fmt.Errorf("Search method is required")
219+
return nil, fmt.Errorf("search method is required")
220220
}
221221

222222
if text == "" {
223-
return nil, fmt.Errorf("Text is required")
223+
return nil, fmt.Errorf("text is required")
224224
}
225225

226226
sOpts := &SearchOptions{
@@ -236,29 +236,29 @@ func Search(collection, searchMethod, text string, opts ...SearchOption) (*Colle
236236
result := hostSearch(&collection, &sOpts.namespaces, &searchMethod, &text, int32(sOpts.limit), sOpts.returnText)
237237

238238
if result == nil {
239-
return nil, fmt.Errorf("Failed to search")
239+
return nil, fmt.Errorf("failed to search")
240240
}
241241

242242
return result, nil
243243
}
244244

245245
func SearchByVector(collection, searchMethod string, vector []float32, opts ...SearchOption) (*CollectionSearchResult, error) {
246246
if collection == "" {
247-
return nil, fmt.Errorf("Collection name is required")
247+
return nil, fmt.Errorf("collection name is required")
248248
}
249249

250250
if searchMethod == "" {
251-
return nil, fmt.Errorf("Search method is required")
251+
return nil, fmt.Errorf("search method is required")
252252
}
253253

254254
if len(vector) == 0 {
255255
return &CollectionSearchResult{
256256
Collection: collection,
257257
Status: Error,
258-
Error: "Vector is required",
258+
Error: "vector is required",
259259
SearchMethod: "",
260260
Objects: nil,
261-
}, fmt.Errorf("Vector is required")
261+
}, fmt.Errorf("vector is required")
262262
}
263263

264264
sOpts := &SearchOptions{
@@ -274,23 +274,23 @@ func SearchByVector(collection, searchMethod string, vector []float32, opts ...S
274274
result := hostSearchByVector(&collection, &sOpts.namespaces, &searchMethod, &vector, int32(sOpts.limit), sOpts.returnText)
275275

276276
if result == nil {
277-
return nil, fmt.Errorf("Failed to search")
277+
return nil, fmt.Errorf("failed to search")
278278
}
279279

280280
return result, nil
281281
}
282282

283283
func NnClassify(collection, searchMethod, text string, opts ...NamespaceOption) (*CollectionClassificationResult, error) {
284284
if collection == "" {
285-
return nil, fmt.Errorf("Collection name is required")
285+
return nil, fmt.Errorf("collection name is required")
286286
}
287287

288288
if searchMethod == "" {
289-
return nil, fmt.Errorf("Search method is required")
289+
return nil, fmt.Errorf("search method is required")
290290
}
291291

292292
if text == "" {
293-
return nil, fmt.Errorf("Text is required")
293+
return nil, fmt.Errorf("text is required")
294294
}
295295

296296
nsOpts := &NamespaceOptions{
@@ -304,19 +304,19 @@ func NnClassify(collection, searchMethod, text string, opts ...NamespaceOption)
304304
result := hostClassifyText(&collection, &nsOpts.namespace, &searchMethod, &text)
305305

306306
if result == nil {
307-
return nil, fmt.Errorf("Failed to classify")
307+
return nil, fmt.Errorf("failed to classify")
308308
}
309309

310310
return result, nil
311311
}
312312

313313
func RecomputeSearchMethod(collection, searchMethod string, opts ...NamespaceOption) (*SearchMethodMutationResult, error) {
314314
if collection == "" {
315-
return nil, fmt.Errorf("Collection name is required")
315+
return nil, fmt.Errorf("collection name is required")
316316
}
317317

318318
if searchMethod == "" {
319-
return nil, fmt.Errorf("Search method is required")
319+
return nil, fmt.Errorf("search method is required")
320320
}
321321

322322
nsOpts := &NamespaceOptions{
@@ -330,27 +330,27 @@ func RecomputeSearchMethod(collection, searchMethod string, opts ...NamespaceOpt
330330
result := hostRecomputeIndex(&collection, &nsOpts.namespace, &searchMethod)
331331

332332
if result == nil {
333-
return nil, fmt.Errorf("Failed to recompute")
333+
return nil, fmt.Errorf("failed to recompute")
334334
}
335335

336336
return result, nil
337337
}
338338

339339
func ComputeDistance(collection, searchMethod, key1, key2 string, opts ...NamespaceOption) (*CollectionSearchResultObject, error) {
340340
if collection == "" {
341-
return nil, fmt.Errorf("Collection name is required")
341+
return nil, fmt.Errorf("collection name is required")
342342
}
343343

344344
if searchMethod == "" {
345-
return nil, fmt.Errorf("Search method is required")
345+
return nil, fmt.Errorf("search method is required")
346346
}
347347

348348
if key1 == "" {
349-
return nil, fmt.Errorf("Key1 is required")
349+
return nil, fmt.Errorf("key1 is required")
350350
}
351351

352352
if key2 == "" {
353-
return nil, fmt.Errorf("Key2 is required")
353+
return nil, fmt.Errorf("key2 is required")
354354
}
355355

356356
nsOpts := &NamespaceOptions{
@@ -364,19 +364,19 @@ func ComputeDistance(collection, searchMethod, key1, key2 string, opts ...Namesp
364364
result := hostComputeDistance(&collection, &nsOpts.namespace, &searchMethod, &key1, &key2)
365365

366366
if result == nil {
367-
return nil, fmt.Errorf("Failed to compute distance")
367+
return nil, fmt.Errorf("failed to compute distance")
368368
}
369369

370370
return result, nil
371371
}
372372

373373
func GetText(collection, key string, opts ...NamespaceOption) (string, error) {
374374
if collection == "" {
375-
return "", fmt.Errorf("Collection name is required")
375+
return "", fmt.Errorf("collection name is required")
376376
}
377377

378378
if key == "" {
379-
return "", fmt.Errorf("Key is required")
379+
return "", fmt.Errorf("key is required")
380380
}
381381

382382
nsOpts := &NamespaceOptions{
@@ -390,15 +390,15 @@ func GetText(collection, key string, opts ...NamespaceOption) (string, error) {
390390
result := hostGetText(&collection, &nsOpts.namespace, &key)
391391

392392
if result == nil {
393-
return "", fmt.Errorf("Failed to get text for key")
393+
return "", fmt.Errorf("failed to get text for key")
394394
}
395395

396396
return *result, nil
397397
}
398398

399399
func GetTexts(collection string, opts ...NamespaceOption) (map[string]string, error) {
400400
if collection == "" {
401-
return nil, fmt.Errorf("Collection name is required")
401+
return nil, fmt.Errorf("collection name is required")
402402
}
403403

404404
nsOpts := &NamespaceOptions{
@@ -412,37 +412,37 @@ func GetTexts(collection string, opts ...NamespaceOption) (map[string]string, er
412412
result := hostDumpTexts(&collection, &nsOpts.namespace)
413413

414414
if result == nil {
415-
return nil, fmt.Errorf("Failed to get texts")
415+
return nil, fmt.Errorf("failed to get texts")
416416
}
417417

418418
return *result, nil
419419
}
420420

421421
func GetNamespaces(collection string) ([]string, error) {
422422
if collection == "" {
423-
return nil, fmt.Errorf("Collection name is required")
423+
return nil, fmt.Errorf("collection name is required")
424424
}
425425

426426
result := hostGetNamespaces(&collection)
427427

428428
if result == nil {
429-
return nil, fmt.Errorf("Failed to get namespaces")
429+
return nil, fmt.Errorf("failed to get namespaces")
430430
}
431431

432432
return *result, nil
433433
}
434434

435435
func GetVector(collection, searchMethod, key string, opts ...NamespaceOption) ([]float32, error) {
436436
if collection == "" {
437-
return nil, fmt.Errorf("Collection name is required")
437+
return nil, fmt.Errorf("collection name is required")
438438
}
439439

440440
if searchMethod == "" {
441-
return nil, fmt.Errorf("Search method is required")
441+
return nil, fmt.Errorf("search method is required")
442442
}
443443

444444
if key == "" {
445-
return nil, fmt.Errorf("Key is required")
445+
return nil, fmt.Errorf("key is required")
446446
}
447447

448448
nsOpts := &NamespaceOptions{
@@ -456,19 +456,19 @@ func GetVector(collection, searchMethod, key string, opts ...NamespaceOption) ([
456456
result := hostGetVector(&collection, &nsOpts.namespace, &searchMethod, &key)
457457

458458
if result == nil {
459-
return nil, fmt.Errorf("Failed to get vector for key")
459+
return nil, fmt.Errorf("failed to get vector for key")
460460
}
461461

462462
return *result, nil
463463
}
464464

465465
func GetLabels(collection, key string, opts ...NamespaceOption) ([]string, error) {
466466
if collection == "" {
467-
return nil, fmt.Errorf("Collection name is required")
467+
return nil, fmt.Errorf("collection name is required")
468468
}
469469

470470
if key == "" {
471-
return nil, fmt.Errorf("Key is required")
471+
return nil, fmt.Errorf("key is required")
472472
}
473473

474474
nsOpts := &NamespaceOptions{

0 commit comments

Comments
 (0)