From f574429f5ec8bcaa984ca5edeb242bb552eba167 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 10 Jan 2016 21:26:55 +0800 Subject: [PATCH] Return pointer when Open --- main.go | 4 ++-- main_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 9fe6cf4e..f6cd66ad 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ type DB struct { joinTableHandlers map[string]JoinTableHandler } -func Open(dialect string, args ...interface{}) (DB, error) { +func Open(dialect string, args ...interface{}) (*DB, error) { var db DB var err error @@ -79,7 +79,7 @@ func Open(dialect string, args ...interface{}) (DB, error) { } } - return db, err + return &db, err } func (s *DB) Close() error { diff --git a/main_test.go b/main_test.go index e6c703e4..d288b8ad 100644 --- a/main_test.go +++ b/main_test.go @@ -20,7 +20,7 @@ import ( ) var ( - DB gorm.DB + DB *gorm.DB t1, t2, t3, t4, t5 time.Time ) @@ -41,7 +41,7 @@ func init() { runMigration() } -func OpenTestConnection() (db gorm.DB, err error) { +func OpenTestConnection() (db *gorm.DB, err error) { switch os.Getenv("GORM_DIALECT") { case "mysql": // CREATE USER 'gorm'@'localhost' IDENTIFIED BY 'gorm';