mirror of
https://github.com/bootdotdev/fcc-learn-golang-assets.git
synced 2025-12-15 09:41:17 +00:00
47 lines
930 B
Go
47 lines
930 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func getUserMap(names []string, phoneNumbers []int) (map[string]user, error) {
|
|
// ?
|
|
}
|
|
|
|
// don't touch below this line
|
|
|
|
type user struct {
|
|
name string
|
|
phoneNumber int
|
|
}
|
|
|
|
func test(names []string, phoneNumbers []int) {
|
|
fmt.Println("Creating map...")
|
|
defer fmt.Println("====================================")
|
|
users, err := getUserMap(names, phoneNumbers)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
for _, name := range names {
|
|
fmt.Printf("key: %v, value:\n", name)
|
|
fmt.Println(" - name:", users[name].name)
|
|
fmt.Println(" - number:", users[name].phoneNumber)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
test(
|
|
[]string{"John", "Bob", "Jill"},
|
|
[]int{14355550987, 98765550987, 18265554567},
|
|
)
|
|
test(
|
|
[]string{"John", "Bob"},
|
|
[]int{14355550987, 98765550987, 18265554567},
|
|
)
|
|
test(
|
|
[]string{"George", "Sally", "Rich", "Sue"},
|
|
[]int{20955559812, 38385550982, 48265554567, 16045559873},
|
|
)
|
|
}
|