Kaynağa Gözat

check for nil

Darien Raymond 8 yıl önce
ebeveyn
işleme
07866e6d39
1 değiştirilmiş dosya ile 6 ekleme ve 0 silme
  1. 6 0
      app/space.go

+ 6 - 0
app/space.go

@@ -72,11 +72,17 @@ func (v *spaceImpl) Initialize() error {
 }
 
 func (v *spaceImpl) GetApplication(appInterface interface{}) Application {
+	if v == nil {
+		return nil
+	}
 	appType := reflect.TypeOf(appInterface)
 	return v.cache[appType]
 }
 
 func (v *spaceImpl) AddApplication(app Application) error {
+	if v == nil {
+		return errors.New("App: Nil space.")
+	}
 	appType := reflect.TypeOf(app.Interface())
 	v.cache[appType] = app
 	return nil