1.3.0: code: fix close issue #1
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
98cdbaef90
commit
1992280022
2 changed files with 38 additions and 7 deletions
|
|
@ -43,7 +43,7 @@ func Init_database(dsn string) (*gorm.DB, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return db, err
|
return db, err
|
||||||
}
|
}
|
||||||
db.AutoMigrate(&Users{})
|
_ = db.AutoMigrate(&Users{})
|
||||||
DropUnusedColumns(db, &Users{})
|
DropUnusedColumns(db, &Users{})
|
||||||
|
|
||||||
return db, nil
|
return db, nil
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package lib
|
||||||
import (
|
import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -22,7 +23,12 @@ func InitLoginBiscuit() error {
|
||||||
if file, err := os.Create(filePrivateKey); err != nil {
|
if file, err := os.Create(filePrivateKey); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if cerr := file.Close(); cerr != nil {
|
||||||
|
// ici tu peux logger ou faire quelque chose
|
||||||
|
fmt.Printf("Erreur à la fermeture: %v\n", cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if _, err = io.WriteString(file, string(PrivateKey)); err != nil {
|
if _, err = io.WriteString(file, string(PrivateKey)); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -34,7 +40,12 @@ func InitLoginBiscuit() error {
|
||||||
if file, err := os.Create(filePublicKey); err != nil {
|
if file, err := os.Create(filePublicKey); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if cerr := file.Close(); cerr != nil {
|
||||||
|
// ici tu peux logger ou faire quelque chose
|
||||||
|
fmt.Printf("Erreur à la fermeture: %v\n", cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if _, err = io.WriteString(file, string(PublicKey)); err != nil {
|
if _, err = io.WriteString(file, string(PublicKey)); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -47,7 +58,12 @@ func InitLoginBiscuit() error {
|
||||||
if file, err := os.Open(filePrivateKey); err != nil {
|
if file, err := os.Open(filePrivateKey); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if cerr := file.Close(); cerr != nil {
|
||||||
|
// ici tu peux logger ou faire quelque chose
|
||||||
|
fmt.Printf("Erreur à la fermeture: %v\n", cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
PrivateKey, err = io.ReadAll(file)
|
PrivateKey, err = io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -57,7 +73,12 @@ func InitLoginBiscuit() error {
|
||||||
if file, err := os.Open(filePublicKey); err != nil {
|
if file, err := os.Open(filePublicKey); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if cerr := file.Close(); cerr != nil {
|
||||||
|
// ici tu peux logger ou faire quelque chose
|
||||||
|
fmt.Printf("Erreur à la fermeture: %v\n", cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
PublicKey, err = io.ReadAll(file)
|
PublicKey, err = io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -86,7 +107,12 @@ func InitGlobalBiscuit() error {
|
||||||
if file, err := os.Open(filePrivateKey); err != nil {
|
if file, err := os.Open(filePrivateKey); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if cerr := file.Close(); cerr != nil {
|
||||||
|
// ici tu peux logger ou faire quelque chose
|
||||||
|
fmt.Printf("Erreur à la fermeture: %v\n", cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
PrivateKey, err = io.ReadAll(file)
|
PrivateKey, err = io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -96,7 +122,12 @@ func InitGlobalBiscuit() error {
|
||||||
if file, err := os.Open(filePublicKey); err != nil {
|
if file, err := os.Open(filePublicKey); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
if cerr := file.Close(); cerr != nil {
|
||||||
|
// ici tu peux logger ou faire quelque chose
|
||||||
|
fmt.Printf("Erreur à la fermeture: %v\n", cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
PublicKey, err = io.ReadAll(file)
|
PublicKey, err = io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue