From 51ef3774ab45dcaa4dfac798335816ce3177f741 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Mon, 30 Jun 2025 13:38:36 -0400 Subject: [PATCH] Use connection::from_uri method in Go bindings --- bindings/go/rs_src/lib.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/bindings/go/rs_src/lib.rs b/bindings/go/rs_src/lib.rs index 035a3ac40..9029a6966 100644 --- a/bindings/go/rs_src/lib.rs +++ b/bindings/go/rs_src/lib.rs @@ -6,7 +6,7 @@ use std::{ ffi::{c_char, c_void}, sync::Arc, }; -use turso_core::{Connection, Database, LimboError, IO}; +use turso_core::{Connection, LimboError}; /// # Safety /// Safe to be called from Go with null terminated DSN string. @@ -20,21 +20,10 @@ pub unsafe extern "C" fn db_open(path: *const c_char) -> *mut c_void { } let path = unsafe { std::ffi::CStr::from_ptr(path) }; let path = path.to_str().unwrap(); - let io: Arc = match path { - p if p.contains(":memory:") => Arc::new(turso_core::MemoryIO::new()), - _ => Arc::new(turso_core::PlatformIO::new().expect("Failed to create IO")), + let Ok((io, conn)) = Connection::from_uri(path) else { + panic!("Failed to open connection with path: {}", path); }; - let db = Database::open_file(io.clone(), path, false, false); - match db { - Ok(db) => { - let conn = db.connect().unwrap(); - LimboConn::new(conn, io).to_ptr() - } - Err(e) => { - eprintln!("Error: {}", e); - std::ptr::null_mut() - } - } + LimboConn::new(conn, io).to_ptr() } #[allow(dead_code)]