MCPcopy
hub / github.com/tinyauthapp/tinyauth / GetUsers

Function GetUsers

internal/utils/user_utils.go:33–63  ·  view source on GitHub ↗
(usersCfg []string, usersPath string)

Source from the content-addressed store, hash-verified

31}
32
33func GetUsers(usersCfg []string, usersPath string) ([]config.User, error) {
34 var usersStr []string
35
36 if len(usersCfg) == 0 && usersPath == "" {
37 return []config.User{}, nil
38 }
39
40 if len(usersCfg) > 0 {
41 usersStr = append(usersStr, usersCfg...)
42 }
43
44 if usersPath != "" {
45 contents, err := ReadFile(usersPath)
46
47 if err != nil {
48 return []config.User{}, err
49 }
50
51 lines := strings.SplitSeq(contents, "\n")
52
53 for line := range lines {
54 lineTrimmed := strings.TrimSpace(line)
55 if lineTrimmed == "" {
56 continue
57 }
58 usersStr = append(usersStr, lineTrimmed)
59 }
60 }
61
62 return ParseUsers(usersStr)
63}
64
65func ParseUser(userStr string) (config.User, error) {
66 if strings.Contains(userStr, "$$") {

Callers 2

TestGetUsersFunction · 0.92
SetupMethod · 0.92

Calls 2

ReadFileFunction · 0.85
ParseUsersFunction · 0.85

Tested by 1

TestGetUsersFunction · 0.74