Skip to content

Commit 620b1ca

Browse files
committed
Improved examples [skip ci]
1 parent 089c0b5 commit 620b1ca

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/citus/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"math/rand"
6+
"math/rand/v2"
77

88
"github.com/jackc/pgx/v5"
99
"github.com/pgvector/pgvector-go"
@@ -22,7 +22,7 @@ func main() {
2222
embedding = append(embedding, rand.Float32())
2323
}
2424
embeddings = append(embeddings, embedding)
25-
categories = append(categories, int64(rand.Intn(100)))
25+
categories = append(categories, int64(rand.IntN(100)))
2626
}
2727

2828
// enable extensions
@@ -109,7 +109,7 @@ func main() {
109109

110110
fmt.Println("Running distributed queries")
111111
for i := 0; i < 10; i++ {
112-
rows, err := conn.Query(ctx, "SELECT id FROM items ORDER BY embedding <-> $1 LIMIT 10", pgvector.NewVector(embeddings[rand.Intn(rows)]))
112+
rows, err := conn.Query(ctx, "SELECT id FROM items ORDER BY embedding <-> $1 LIMIT 10", pgvector.NewVector(embeddings[rand.IntN(rows)]))
113113
if err != nil {
114114
panic(err)
115115
}

examples/loading/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"math/rand"
6+
"math/rand/v2"
77

88
"github.com/jackc/pgx/v5"
99
"github.com/pgvector/pgvector-go"

0 commit comments

Comments
 (0)