Skip to content

egasimov/lancedb-go

 
 

Repository files navigation

LanceDB Go SDK

A Go library for LanceDB.

Installation

go get github.com/lancedb/lancedb-go/pkg

Usage

Basic Example

import lancedb "github.com/lancedb/lancedb-go/pkg"

// Connect to a database
ctx := context.Background()
db, err := lancedb.Connect(ctx, "data/sample-lancedb", nil)
if err != nil {
    log.Fatal(err)
}
defer db.Close()

// Create a table with schema
schema := lancedb.NewSchemaBuilder().
    AddInt32Field("id", false).
    AddStringField("text", false).
    AddVectorField("vector", 128, lancedb.VectorDataTypeFloat32, false).
    Build()

table, err := db.CreateTable(ctx, "my_table", *schema)
if err != nil {
    log.Fatal(err)
}
defer table.Close()

// Perform vector search
queryVector := []float32{0.1, 0.3, /* ... 128 dimensions */}
results, err := table.VectorSearch("vector", queryVector, 20)
if err != nil {
    log.Fatal(err)
}
fmt.Println(results)

The quickstart guide contains more complete examples.

Development

Quick Start

# Install all development dependencies
make install-deps

# Build the project
make build

# Run tests
make test

# Lint code (requires golangci-lint)
make lint

# Format code
make fmt

Go Linting

This project uses golangci-lint for comprehensive Go code linting:

# Install golangci-lint (included in install-deps)
make install-deps

# Lint Go code
make lint-go

# Lint and auto-fix issues
make lint-go-fix

See CONTRIBUTING.md for detailed development guidelines, linting configuration, and contribution instructions.

About

LanceDB Go SDK

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 55.2%
  • Rust 38.2%
  • Makefile 6.6%