On Sat, 2023-10-14 at 09:33 -0700, Tong Sun wrote: > Please take a look at > https://go.dev/play/p/dTDR50dtHB0 > > I want to > > - define my template data dynamically from yaml > - and export the yaml data if they are unexported > > I.e., for the following code: > > t := template.New("") > t, err = t.Parse("It's {{.A}} {{.B.C}}!\n") > if err != nil { > log.Fatalf("error: %v", err) > } > t.Execute(os.Stdout, m) > > The input is `map[A:Easy! B:map[C:2 D:[3 4]]]`. > But why the template was not able to produce any output for the > dynamic fields?
It is trying to match a string to a main.MyKey. If the only reason you are using that type is to change the case of the key strings, I'd just index into the lowercase, https://go.dev/play/p/wi9KICK1zmW. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/fee9f5570d0c9370b4ecf3c667df98b4f6a6f0b7.camel%40kortschak.io.