diff --git a/05_hash_tables/golang/01_price_of_groceries.go b/05_hash_tables/golang/01_price_of_groceries.go new file mode 100644 index 0000000..daba2dd --- /dev/null +++ b/05_hash_tables/golang/01_price_of_groceries.go @@ -0,0 +1,13 @@ +package main + +import "fmt" + +var book map[string]float64 + +func main() { + book = make(map[string]float64) + book["apple"] = 0.67 + book["milk"] = 1.49 + book["avocado"] = 1.49 + fmt.Println(book) +} diff --git a/05_hash_tables/golang/02_check_voter.go b/05_hash_tables/golang/02_check_voter.go new file mode 100644 index 0000000..4da9544 --- /dev/null +++ b/05_hash_tables/golang/02_check_voter.go @@ -0,0 +1,21 @@ +package main + +import "fmt" + +var voted map[string]bool + +func main() { + voted = make(map[string]bool) + check_voter("tom") + check_voter("mike") + check_voter("mike") +} + +func check_voter(name string) { + if voted[name] { + fmt.Println("kick tem out!") + } else { + voted[name] = true + fmt.Println("let tem vote!") + } +}