Add any type and output errors

This commit is contained in:
Archie Fox
2025-03-14 15:11:17 +03:00
parent debf1eec22
commit e7bb6ba60a
4 changed files with 25 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ package files
import (
"fmt"
"os"
"password/output"
)
type JsonDb struct {
@@ -26,13 +27,13 @@ func (db *JsonDb) Read() ([]byte, error) {
func (db *JsonDb) Write(content []byte) {
file, err := os.Create(db.filename)
if err != nil {
fmt.Println(err)
output.PrintError(err)
}
defer file.Close()
_, err = file.Write(content)
if err != nil {
file.Close()
fmt.Println(err)
output.PrintError(err)
return
}
fmt.Println("Файл успешно записан")