All the boilerplate needed for a Turso or LibSQL golang project to work on all platforms.
Go to file
Mason Payne 97fb4e290e update example in readme 2024-10-16 18:23:52 -06:00
.idea update readme 2024-09-02 14:58:46 -06:00
examples/basic-usage move-migrations-to-option (#1) 2024-10-16 18:04:01 -06:00
LICENSE add license file 2024-10-16 18:22:29 -06:00
db.go move-migrations-to-option (#1) 2024-10-16 18:04:01 -06:00
embedded.go move-migrations-to-option (#1) 2024-10-16 18:04:01 -06:00
go.mod refactor into an importable library and keep an example 2024-08-22 00:05:50 -06:00
go.sum initial commit 2024-08-19 01:07:19 -06:00
readme.md update example in readme 2024-10-16 18:23:52 -06:00
remote-only.go move-migrations-to-option (#1) 2024-10-16 18:04:01 -06:00

readme.md

Go LibSQL DualDriver

Welcome to the Go LibSQL DualDriver! This library provides a seamless interface for connecting to LibSQL databases, whether youre working on Windows or other platforms. By automatically switching between the remote LibSQL driver for Windows and the embedded driver for other platforms, this wrapper ensures that your development environment is as close to production as possible.

Key Features

  • Cross-Platform Support: Automatically chooses the appropriate driver—remote for Windows, embedded for other systems.
  • Built-in Migration Tool: Simplifies database migrations by allowing you to embed SQL files directly in your Go code.

Getting Started

Installation

To start using this library, simply import it and initialize the database connection in your Go application. The library will handle the rest.

Example Usage

Heres a quick example of how to set up a database connection with embedded migration files:

//go:embed migrations/*.sql
var migrationFiles embed.FS

tdb, err := libsqldb.NewLibSqlDB(
    primaryUrl,
    libsqldb.WithMigrationFiles(migrationFiles),
    libsqldb.WithAuthToken(authToken),
    libsqldb.WithLocalDBName("local.db"), // will not be used for remote-only
)

Why Use This Library?

I developed this library to streamline the process of setting up a database connection in Go, complete with built-in migration capabilities. During development, I encountered issues with using the embedded driver on Windows. As I researched, I discovered others had similar issues. This wrapper solves that problem by automatically selecting the appropriate driver based on your operating system.

Special Note for Windows Users

This library defaults to using the embedded driver for better performance and closer parity with production environments. However, due to the lack of support for embedded LibSQL on Windows, this library uses a remote driver when running on Windows. Special build tags are included to ensure seamless operation across platforms.

Feel free to explore the repository and experiment with the examples provided. Happy coding!