12345678910111213141516171819202122232425262728 |
- package models
- import (
- "database/sql"
- "log"
- _ "github.com/go-sql-driver/mysql"
- )
- var db *sql.DB
- func Init(dataSourceName string) error {
- var err error
- db, err = sql.Open("mysql", dataSourceName)
- if err != nil {
- log.Panic(err)
- }
- if err = db.Ping(); err != nil {
- log.Panic(err)
- }
- return err
- }
|