bindings/go: Adjust tests for multiple concurrent connections

This commit is contained in:
PThorpe92 2025-01-30 13:09:39 -05:00
parent 98579ab2e4
commit 950f29daab
No known key found for this signature in database
GPG key ID: 66DB3FBACBDD05CC
9 changed files with 322 additions and 272 deletions

View file

@ -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{})
}