-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.go
51 lines (35 loc) · 780 Bytes
/
users.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"errors"
)
type Users struct {
Users []User `toml:"users"`
}
type User struct {
Name string
Uuid string
OfflineUuid string
}
// func getUserByUuid(uuid string) (User, error) {
// for _, user := range users.Users {
// if user.Uuid == uuid || user.OfflineUuid == uuid {
// return user, nil
// }
// }
// return User{}, errors.New("Uuid no encontrado en el sistema")
// }
func getUserByName(name string) (User, error) {
for _, user := range users.Users {
if user.Name == name {
return user, nil
}
}
return User{}, errors.New("Nombre no encontrado en el sistema")
}
func getUsersNames() []string {
var names []string
for _, user := range users.Users {
names = append(names, user.Name)
}
return names
}