mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 10:08:20 +00:00
bindings/go: Adjust tests for multiple concurrent connections
This commit is contained in:
parent
98579ab2e4
commit
950f29daab
9 changed files with 322 additions and 272 deletions
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/ebitengine/purego"
|
||||
)
|
||||
|
||||
func loadLibrary() error {
|
||||
func loadLibrary() (uintptr, error) {
|
||||
var libraryName string
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
|
@ -21,14 +21,14 @@ func loadLibrary() error {
|
|||
case "linux":
|
||||
libraryName = fmt.Sprintf("%s.so", libName)
|
||||
default:
|
||||
return fmt.Errorf("GOOS=%s is not supported", runtime.GOOS)
|
||||
return 0, fmt.Errorf("GOOS=%s is not supported", runtime.GOOS)
|
||||
}
|
||||
|
||||
libPath := os.Getenv("LD_LIBRARY_PATH")
|
||||
paths := strings.Split(libPath, ":")
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
paths = append(paths, cwd)
|
||||
|
||||
|
@ -37,20 +37,18 @@ func loadLibrary() error {
|
|||
if _, err := os.Stat(libPath); err == nil {
|
||||
slib, dlerr := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
|
||||
if dlerr != nil {
|
||||
return fmt.Errorf("failed to load library at %s: %w", libPath, dlerr)
|
||||
return 0, fmt.Errorf("failed to load library at %s: %w", libPath, dlerr)
|
||||
}
|
||||
limboLib = slib
|
||||
return nil
|
||||
return slib, nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("%s library not found in LD_LIBRARY_PATH or CWD", libName)
|
||||
return 0, fmt.Errorf("%s library not found in LD_LIBRARY_PATH or CWD", libName)
|
||||
}
|
||||
|
||||
func init() {
|
||||
err := loadLibrary()
|
||||
err := ensureLibLoaded()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
panic(err)
|
||||
}
|
||||
sql.Register("sqlite3", &limboDriver{})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue