diff --git a/myconf/conf_test.go b/myconf/conf_test.go deleted file mode 100644 index 3158e14..0000000 --- a/myconf/conf_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package myconf - -import ( - "fmt" - "testing" -) - -func TestConf(t *testing.T) { - type Config struct { - App struct { - Name string - Addr string - Port int - } - - Redis struct { - Addr string - Db int - } - } - - var config = &Config{} - Init("test.yaml", config) - fmt.Printf("%+v\n", config) -} diff --git a/mymysql/mysql.go b/mymysql/mysql.go index a66f557..bf39564 100644 --- a/mymysql/mysql.go +++ b/mymysql/mysql.go @@ -53,17 +53,16 @@ func DB(key ...string) *gorm.DB { return instance } -func InitDefault(config *Config) error { - return Init(DefaultKey, config) +func InitDefault(config *Config) { + Init(DefaultKey, config) } -func Init(key string, config *Config) error { +func Init(key string, config *Config) { db, err := New(config) if err != nil { - return err + panic(err) } instanceMap[key] = db - return nil } func New(config *Config) (*gorm.DB, error) {