-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DESKTOP-LKF81KV\Mak Moinee
committed
Oct 21, 2022
1 parent
61309e2
commit bbf5042
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/MakMoinee/go-mith | ||
|
||
go 1.18 | ||
go 1.19 | ||
|
||
require ( | ||
github.com/go-chi/chi v1.5.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package mysql | ||
|
||
import ( | ||
"database/sql" | ||
"log" | ||
) | ||
|
||
type service struct { | ||
DatabaseName string | ||
DatabaseServer string | ||
DatabaseUser string | ||
DatabasePassword string | ||
ConnectionString string | ||
Db *sql.DB | ||
DbDriver string | ||
} | ||
|
||
type GoMithMysql interface { | ||
GetDBConnection() *sql.DB | ||
} | ||
|
||
func NewGoMithMysql(dbName, dbServer, dbUser, dbPassword, dbDriver string) GoMithMysql { | ||
svc := service{} | ||
|
||
return &svc | ||
} | ||
|
||
func (s *service) GetDBConnection() *sql.DB { | ||
db, err := sql.Open(s.DbDriver, s.ConnectionString) | ||
if err != nil { | ||
log.Println(err.Error()) | ||
} | ||
return db | ||
} |