Check error before deferring db.Close() (#491)

pull/493/head^2
Sebastian Ehmann 5 years ago committed by Roberto Rojas
parent b9be7daa4a
commit 09fb3c4fe4

@ -49,11 +49,11 @@ func savePgsql(jsonInfo string) {
}
db, err := gorm.Open("postgres", connInfo)
defer db.Close()
if err != nil {
exitWithError(fmt.Errorf("received error connecting to database: %s", err))
}
defer db.Close()
db.Debug().AutoMigrate(&ScanResult{})
db.Save(&ScanResult{ScanHost: hostname, ScanTime: timestamp, ScanInfo: jsonInfo})
glog.V(2).Info(fmt.Sprintf("successfully stored result to: %s", envVars["PGSQL_HOST"]))

Loading…
Cancel
Save