diff --git a/README.md b/README.md index e5e6665..43695ff 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,11 @@ And follow the instructions for your database library: Or check out some examples: -- [Embeddings](examples/openai_test.go) with OpenAI -- [Binary embeddings](examples/cohere_test.go) with Cohere -- [Recommendations](examples/disco_test.go) with Disco -- [Horizontal scaling](examples/citus_test.go) with Citus -- [Bulk loading](examples/loading_test.go) with `COPY` +- [Embeddings](examples/openai/main.go) with OpenAI +- [Binary embeddings](examples/cohere/main.go) with Cohere +- [Recommendations](examples/disco/main.go) with Disco +- [Horizontal scaling](examples/citus/main.go) with Citus +- [Bulk loading](examples/loading/main.go) with `COPY` ## pgx @@ -385,5 +385,5 @@ go test -v To run an example: ```sh -go test -v examples/loading_test.go +go run ./examples/loading ``` diff --git a/examples/citus_test.go b/examples/citus/main.go similarity index 98% rename from examples/citus_test.go rename to examples/citus/main.go index 46d123c..6d735f0 100644 --- a/examples/citus_test.go +++ b/examples/citus/main.go @@ -1,17 +1,16 @@ -package pgvector_test +package main import ( "context" "fmt" "math/rand" - "testing" "github.com/jackc/pgx/v5" "github.com/pgvector/pgvector-go" pgxvector "github.com/pgvector/pgvector-go/pgx" ) -func TestCitus(t *testing.T) { +func main() { // generate random data rows := 1000000 dimensions := 128 diff --git a/examples/cohere_test.go b/examples/cohere/main.go similarity index 97% rename from examples/cohere_test.go rename to examples/cohere/main.go index 821e192..94905d7 100644 --- a/examples/cohere_test.go +++ b/examples/cohere/main.go @@ -1,4 +1,4 @@ -package pgvector_test +package main import ( "bytes" @@ -7,15 +7,15 @@ import ( "fmt" "net/http" "os" - "testing" "github.com/jackc/pgx/v5" ) -func TestCohere(t *testing.T) { +func main() { apiKey := os.Getenv("CO_API_KEY") if apiKey == "" { - t.Skip("Set CO_API_KEY") + fmt.Println("Set CO_API_KEY") + os.Exit(1) } ctx := context.Background() diff --git a/examples/disco_test.go b/examples/disco/main.go similarity index 97% rename from examples/disco_test.go rename to examples/disco/main.go index 6b3265a..2b945c0 100644 --- a/examples/disco_test.go +++ b/examples/disco/main.go @@ -1,16 +1,15 @@ -package pgvector_test +package main import ( "context" "fmt" - "testing" "github.com/ankane/disco-go" "github.com/jackc/pgx/v5" "github.com/pgvector/pgvector-go" ) -func TestDisco(t *testing.T) { +func main() { ctx := context.Background() conn, err := pgx.Connect(ctx, "postgres://localhost/pgvector_example") diff --git a/examples/loading_test.go b/examples/loading/main.go similarity index 96% rename from examples/loading_test.go rename to examples/loading/main.go index 3b48417..c2693be 100644 --- a/examples/loading_test.go +++ b/examples/loading/main.go @@ -1,17 +1,16 @@ -package pgvector_test +package main import ( "context" "fmt" "math/rand" - "testing" "github.com/jackc/pgx/v5" "github.com/pgvector/pgvector-go" pgxvector "github.com/pgvector/pgvector-go/pgx" ) -func TestLoading(t *testing.T) { +func main() { // generate random data rows := 1000000 diff --git a/examples/openai_test.go b/examples/openai/main.go similarity index 96% rename from examples/openai_test.go rename to examples/openai/main.go index dfef601..24ebba0 100644 --- a/examples/openai_test.go +++ b/examples/openai/main.go @@ -1,4 +1,4 @@ -package pgvector_test +package main import ( "bytes" @@ -7,16 +7,16 @@ import ( "fmt" "net/http" "os" - "testing" "github.com/jackc/pgx/v5" "github.com/pgvector/pgvector-go" ) -func TestOpenAI(t *testing.T) { +func main() { apiKey := os.Getenv("OPENAI_API_KEY") if apiKey == "" { - t.Skip("Set OPENAI_API_KEY") + fmt.Println("Set OPENAI_API_KEY") + os.Exit(1) } ctx := context.Background()