-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.go
More file actions
36 lines (31 loc) · 673 Bytes
/
users.go
File metadata and controls
36 lines (31 loc) · 673 Bytes
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
package main
import (
"errors"
)
type user struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
}
// ensure all user fields are populated
func (newUser user) ValidateNewUser() error {
if newUser.ID == "" {
return errors.New("ID not set")
}
if newUser.Email == "" {
return errors.New("Email not set")
}
if newUser.Name == "" {
return errors.New("Name not set")
}
return nil
}
// mock user DB
var users = []user{
{ID: "1", Name: "Foo", Email: "foo@example.com"},
{ID: "2", Name: "Bar", Email: "Bar@example.com"},
{ID: "3", Name: "John", Email: "John@Doh.com"},
}
type email struct {
Email string `json:"email"`
}