Sunday, December 8, 2024
HomeGolangLooping over nested maps - Code Assessment

Looping over nested maps – Code Assessment


Is there anyway I can loop over the internal maps and never simply the principle map?

./prog.go:49:31: can't vary over days (variable of sort interface{})

My code in case no one need to use play area:

bundle important

import (
	"fmt"
)

func important() {
bundle important

import (
	"fmt"
)

func important() {

	var mapData = map[string]interface{}{

		"Monday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Manner, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Tuesday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Manner, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Wednesday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Manner, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Thursday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Manner, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Friday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Manner, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Saturday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Manner, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Sunday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Manner, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
	}

	for _, days := vary mapData {
		fmt.Println("day", days)
		for _, appointment := vary days {
			fmt.Println("appointment", appointment)
		}

	}

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments