-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.go
More file actions
61 lines (53 loc) · 1.47 KB
/
Copy pathfunctions.go
File metadata and controls
61 lines (53 loc) · 1.47 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"strings"
)
func AddContact() {
fmt.Print("Please enter first name: ")
firstName := getInput()
fmt.Print("Please enter last name: ")
lastName := getInput()
fmt.Print("Please enter email address: ")
email := getInput()
fmt.Print("Please enter phone number: ")
phoneNumber := getInput()
newContact := Contact{
FirstName: strings.ToLower(firstName),
LastName: strings.ToLower(lastName),
EmailAddress: email,
PhoneNumber: phoneNumber,
}
contacts = append(contacts, newContact)
saveToFile()
}
func ViewContact() {
fmt.Println("Enter a full name to search for a specific contact")
fmt.Print("or enter a last name to search for matches: ")
contactName := getInput()
if len(strings.Split(contactName, " ")) == 2 {
searchSpecificContact(contactName, "view")
} else {
searchByLastName(contactName)
}
}
func EditContact() {
fmt.Print("Enter the full name of the contact you wish to edit: ")
contactName := getInput()
if len(strings.Split(contactName, " ")) != 2 {
fmt.Println("We only got one name. Editing of contact requires full name.")
getInput()
return
}
searchSpecificContact(contactName, "edit")
}
func DeleteContact() {
fmt.Print("Enter the full name of the contact you wish to delete: ")
contactName := getInput()
if len(strings.Split(contactName, " ")) != 2 {
fmt.Println("We only got one name. Deletion of contact requires full name.")
getInput()
return
}
searchSpecificContact(contactName, "delete")
}