fixed duplicate code

This commit is contained in:
Settel 2021-08-09 10:22:32 +02:00
parent 90e29d995a
commit 1e478ffb3b
2 changed files with 2 additions and 3 deletions

View File

@ -13,9 +13,8 @@ func (app Application) loadUsers() error {
return err return err
} }
for _, file := range files { for _, file := range files {
id := file.Name()[0:6]
fileName := path.Join(dirName, file.Name()) fileName := path.Join(dirName, file.Name())
if usr, err := user.NewUserFromFile(id, fileName); err != nil { if usr, err := user.NewUserFromFile(fileName); err != nil {
return err return err
} else { } else {
app.users[usr.GetId()] = usr app.users[usr.GetId()] = usr

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
) )
func NewUserFromFile(id, fileName string) (*User, error) { func NewUserFromFile(fileName string) (*User, error) {
jsonBytes, err := os.ReadFile(fileName) jsonBytes, err := os.ReadFile(fileName)
if err != nil { if err != nil {
return nil, err return nil, err