Sunday, October 2, 2022
HomeGolangLooping over nested maps - Code Evaluate

Looping over nested maps – Code Evaluate


Is there anyway I can loop over the inside maps and never simply the primary map?

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

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

package deal fundamental

import (
	"fmt"
)

func fundamental() {
package deal fundamental

import (
	"fmt"
)

func fundamental() {

	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