Saturday, October 1, 2022
HomeGolangLooping over nested maps - Code Evaluate

Looping over nested maps – Code Evaluate


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

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

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

package deal primary

import (
	"fmt"
)

func primary() {
package deal primary

import (
	"fmt"
)

func primary() {

	var mapData = map[string]interface{}{

		"Monday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Means, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Tuesday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Means, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Wednesday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Means, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Thursday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Means, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Friday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Means, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Saturday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Means, WA+98003",
			"Second": "",
			"Third":  "Lynwood",
		},
		"Sunday": map[string]interface{}{
			"First":  "34520 sixteenth Ave S, Federal Means, 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