From bcb2f9f307f15c11e9e95301f865e92ab212c80d Mon Sep 17 00:00:00 2001 From: jnesss Date: Fri, 2 May 2025 12:45:30 -0700 Subject: [PATCH] add documentation for new embedded library feature, including usage instructions and implementation notes --- bindings/go/README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/bindings/go/README.md b/bindings/go/README.md index ab50140bb..b831f0596 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -1,14 +1,30 @@ # Limbo driver for Go's `database/sql` library - **NOTE:** this is currently __heavily__ W.I.P and is not yet in a usable state. This driver uses the awesome [purego](https://github.com/ebitengine/purego) library to call C (in this case Rust with C ABI) functions from Go without the use of `CGO`. +## Embedded Library Support + +This driver now includes an embedded library feature that allows you to distribute a single binary without requiring users to set environment variables. The library for your platform is automatically embedded, extracted at runtime, and loaded dynamically. + +To build with embedded library support: +``` +# From the bindings/go directory +./build_lib.sh +``` + +If the embedded library cannot be found or extracted, the driver will fall back to the traditional method of finding the library in the system paths. ## To use: (_UNSTABLE_ testing or development purposes only) -### Linux | MacOS +### Option 1: Using the embedded library (recommended) + +Build the driver with the embedded library as described above, then simply import and use. No environment variables needed! + +### Option 2: Manual library setup + +#### Linux | MacOS _All commands listed are relative to the bindings/go directory in the limbo repository_ @@ -21,7 +37,7 @@ export LD_LIBRARY_PATH="/path/to/limbo/target/debug:$LD_LIBRARY_PATH" ``` -## Windows +#### Windows ``` cargo build --package limbo-go @@ -69,3 +85,7 @@ func main() { } } ``` + +## Implementation Notes + +The embedded library feature was inspired by projects like [go-embed-python](https://github.com/kluctl/go-embed-python), which uses a similar approach for embedding and distributing native libraries with Go applications.