我可以在Golang模板中使用其他变量作为键吗?

I have a data structure that is sometihng like:

map[string]SomeStructure

I have another struct that encapsulates the above plus additional variables and other structs and that's what gets sent to the template:

type page struct {
    Status   map[string]SomeStructure
    Database  []string
}

In my template file I want to be able to do something like

{{ range index .Database}} 
    {{ .Status "KEY".MemberVariableOfSomeStructure }}
{{ end }}

Except I want the "KEY" to be dynamic based on the iterating .Database value.

You can use the index function to access a map.

{{ range .Database }} 
    {{ index $.Status . }}
{{ end }}

See play.