Help me troubleshoot this missing value problem

54 views
Skip to first unread message

Tong Sun

unread,
Jun 19, 2021, 6:05:11 PM6/19/21
to golang-nuts
Please take a look at

https://play.golang.org/p/k_CM_cJgSvJ

line 77 tries to output .FirstKS then .SecondKS if it is not nil

However, there are two cases, the debug output shows there is .SecondKS field but the template thinks there is `<no value>`:

alt MINUS <no value>map[Id:EditorCutLineBackward Shortcut:map[FirstKS:alt MINUS SecondKS:control K]] EditorCutLineBackward
control C <no value>map[Id:RunToCursor Shortcut:map[FirstKS:control C SecondKS:control U]] RunToCursor
 
I've run out of ideas how it could possibly happen. 

Somebody help please. thx


Sean Liao

unread,
Jun 19, 2021, 6:52:23 PM6/19/21
to golang-nuts
You're accessing .SecondKS when it should be .Shortcut.SecondKS (as you correctly do for .Shortcut.FirstKS)


side note: I think it's easier to read if you also use indenting in your templates and use `{{- -}}` to trim leading/trailing whitespace

Tong Sun

unread,
Jun 19, 2021, 7:12:00 PM6/19/21
to golang-nuts
Ah, thanks a lot Sean!

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/3NUjoj_Bakc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4c37e558-296f-4274-b7fd-679f4d50954en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages