package application import ( "os" "path" "sirlab.de/go/knyt/user" ) func (app Application) loadUsers() error { dirName := path.Join(app.config.DataDir, "users") files, err := os.ReadDir(dirName) if err != nil { return err } app.mu.Lock() defer app.mu.Unlock() for _, file := range files { fileName := path.Join(dirName, file.Name()) if usr, err := user.NewUserFromFile(fileName); err != nil { return err } else { app.users[usr.GetId()] = usr } } return nil }