package learning import ( "fmt" "strings" ) type MapVertex struct { Lat, Long float64 } var m map[string]MapVertex func MapLearning() { m = make(map[string]MapVertex) fmt.Println(m) m["Foo"] = MapVertex{ 1.1, 2.2, } fmt.Println(m) } func MapExercise(str_to_count string) map[string]int { // fmt.Println("Hello") test_map := make(map[string]int) // Creating resulting map // Iterating through string for _, char := range str_to_count { // Converting char to actually readable char var converted_char string = string(char) // Checking if this character contains in map keys amount_of_char_in_map, is_inside := test_map[converted_char] if is_inside { // Get current amount of characters test_map[converted_char] = amount_of_char_in_map + 1 } else { test_map[converted_char] = 1 } } fmt.Println(test_map) return test_map } func MapsLearningWords(string_to_parse string) map[string]int { // Declaring resulting map test_map := make(map[string]int) // Splitting string to words var splitted_string []string = strings.Split(string_to_parse, " ") for _, word := range splitted_string { amount_of_words_in_map, is_inside := test_map[word] if is_inside { // Get current amount of characters test_map[word] = amount_of_words_in_map + 1 } else { test_map[word] = 1 } } return test_map }