chore: course completed

This commit is contained in:
2026-08-07 23:22:34 +02:00
parent 013dca68a9
commit d00ed5c591
+16
View File
@@ -2,6 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"time"
"sync"
"booking-app/helper" "booking-app/helper"
) )
@@ -17,6 +19,8 @@ type UserData struct {
numberOfTickets uint numberOfTickets uint
} }
var wg = sync.WaitGroup{}
func main() { func main() {
greetUsers() greetUsers()
@@ -26,6 +30,8 @@ func main() {
if isValidName && isValidEmail && isValidNumber { if isValidName && isValidEmail && isValidNumber {
bookTicket(firstName, lastName, email, userTickets) bookTicket(firstName, lastName, email, userTickets)
wg.Add(1)
go sendTicket(firstName, lastName, email, userTickets)
fmt.Printf("These are all the first names of our bookings: %v\n", buildFirstNames()) fmt.Printf("These are all the first names of our bookings: %v\n", buildFirstNames())
@@ -45,6 +51,16 @@ func main() {
} }
} }
} }
wg.Wait()
}
func sendTicket(firstName string, lastName string, email string, userTickets uint) {
time.Sleep(50 * time.Second)
ticket := fmt.Sprintf("%v tickets for %v %v", userTickets, firstName, lastName)
fmt.Println("#######")
fmt.Printf("Sending ticket:\n %v \nto email address %v\n", ticket, email)
fmt.Println("######")
wg.Done()
} }
func bookTicket(firstName string, lastName string, email string, userTickets uint) { func bookTicket(firstName string, lastName string, email string, userTickets uint) {