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

Function loadUserById

internal/users/copyover.go:87–103  ·  view source on GitHub ↗

loadUserById loads a user record directly from disk by userId.

(userId int)

Source from the content-addressed store, hash-verified

85
86// loadUserById loads a user record directly from disk by userId.
87func loadUserById(userId int) (*UserRecord, error) {
88 userFilePath := util.FilePath(string(configs.GetFilePathsConfig().DataFiles), `/`, `users`, `/`, strconv.Itoa(userId)+`.yaml`)
89
90 data, err := util.ReadFile(userFilePath)
91 if err != nil {
92 return nil, err
93 }
94
95 user := &UserRecord{}
96 if err := yaml.Unmarshal(data, user); err != nil {
97 return nil, err
98 }
99
100 user.Character.Validate()
101
102 return user, nil
103}
104
105// CopyoverContributor returns the users contributor for registration.
106func CopyoverContributor() copyover.Contributor {

Callers 1

CopyoverRestoreMethod · 0.85

Calls 4

FilePathFunction · 0.92
GetFilePathsConfigFunction · 0.92
ReadFileFunction · 0.92
ValidateMethod · 0.65

Tested by

no test coverage detected