Is there a way to display a field of a map[key-string] with value-struct, in html, in golang?


I have a datatype of map[key-string] value-struct, and I’m trying to display a field(Timing) of the struct

I tried all sort of variations for an hour, can’t seem to figure it out. Would appreciate any guidance on this, thank you!

Also apologies on the formatting, am new, do bear with me!
my code


Instead of inner loop, use {{$value.Timing}}.

// You can edit this code!
// Click here and start typing.
package main

import (

type A struct {
    Timing string

func main() {
    inp := `
    {{ range $key,$value:= .}}
        Key:{{$key}}, Timing {{$value.Timing}}
    valueMap := map[string]A{
        "key": A{
            Timing: "1",
    t, err := template.New("test").Parse(inp)
    if err != nil {
    err = t.Execute(os.Stdout, valueMap)
    if err != nil {

Answered By – shubham_asati

Answer Checked By – Mildred Charles (GoLangFix Admin)

Leave a Reply

Your email address will not be published.