fixed duplicate code
This commit is contained in:
parent
90e29d995a
commit
1e478ffb3b
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user