Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Go support. #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Go support. #16

wants to merge 1 commit into from

Conversation

sno6
Copy link

@sno6 sno6 commented Apr 15, 2023

Hey, I've been playing around with sqlite-vss in Go quite a bit recently so thought I'd chuck up an MR.

It doesn't package up the extensions like the ts/py packages, it's just a lightweight wrapper around a Go driver to make things a little easier for Go folks to get up and running.

@asg017
Copy link
Owner

asg017 commented Apr 19, 2023

Hey @sno6 , thanks for the contribution!

I think it's a great idea to add a "how to use sqlite-vss in a Go" example to the README, but not sure about adding a Go module yet. I think like the Python/Node/Deno bindings, I'd like a Go binding solution to solve the "where does the loadable file exist" problem. In this module, a user will still need to download + find the correct sqlite-vss loadable extension for their platform, which isn't very easy.

Instead, I think it should be possible to statically link sqlite-vss as a Go module. That way, if someone imports github.com/asg017/sqlite-vss/go, then sqlite-vss will be compiled and statically linked inside the Go binary.

Unfortunately it won't be easy: this issue seems to suggest it's possible, but sqlite-vss is quite difficult to compile. We can possibly release .o files for different platforms to make this a bit easier, but it'll be a challenge nonetheless.

If you're able to change this PR to just include an example Go code snipper in the README, that'll be great! Otherwise I'll probably add one myself in a few weeks.

Again, thanks for the contribution!

func Open(dbName string, extPath string) (*sql.DB, error) {
sql.Register("sqlite-vss", &sqlite3.SQLiteDriver{
Extensions: []string{
path.Join(extPath, "vector0"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not use path package. please path/filepath instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants