fixed duplicate code
This commit is contained in:
parent
90e29d995a
commit
1e478ffb3b
@ -13,9 +13,8 @@ func (app Application) loadUsers() error {
|
||||
return err
|
||||
}
|
||||
for _, file := range files {
|
||||
id := file.Name()[0:6]
|
||||
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
|
||||
} else {
|
||||
app.users[usr.GetId()] = usr
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NewUserFromFile(id, fileName string) (*User, error) {
|
||||
func NewUserFromFile(fileName string) (*User, error) {
|
||||
jsonBytes, err := os.ReadFile(fileName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user