tranx POST and GET working

cleaned up the getUser function, now returns index to user rather than
*user
This commit is contained in:
dm
2016-08-22 21:00:39 -07:00
parent 6b2f97632d
commit 36a90e04c8
2 changed files with 39 additions and 67 deletions
+7 -5
View File
@@ -35,13 +35,15 @@ func authorizedEmail(e string) bool {
return b
}
func getUser(e string) (*user, error) {
for _, i := range users {
if e == i.Info.Email {
return &i, nil
// getUser returns index of user with given email, otherwise it returns an
// error that it could not find that user
func getUser(e string) (int, error) {
for i, u := range users {
if e == u.Info.Email {
return i, nil
}
}
return &user{}, fmt.Errorf("could not find user")
return 0, fmt.Errorf("could not find user")
}
func addUser(u userInfo) {