MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / SearchUsers

Function SearchUsers

internal/users/search.go:23–34  ·  view source on GitHub ↗

SearchUsers searches for users matching searchName. If searchName is a valid integer, the search matches by userId (exact match only). Otherwise it searches by username: an exact match returns a single result; all prefix matches are returned when there is no exact match. The username search is case

(searchName string)

Source from the content-addressed store, hash-verified

21// result; all prefix matches are returned when there is no exact match. The
22// username search is case-insensitive.
23func SearchUsers(searchName string) []UserSearchResult {
24 if searchName == "" {
25 return nil
26 }
27
28 // Numeric input: match by userId.
29 if uid, err := strconv.Atoi(searchName); err == nil && uid > 0 {
30 return searchByUserId(uid)
31 }
32
33 return searchByUsername(searchName)
34}
35
36func searchByUserId(uid int) []UserSearchResult {
37 type candidate struct {

Callers 1

apiV1SearchUsersFunction · 0.92

Calls 2

searchByUserIdFunction · 0.85
searchByUsernameFunction · 0.85

Tested by

no test coverage detected