update
						commit
						85d7510113
					
				|  | @ -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) | ||||
| } | ||||
|  | @ -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) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue