How do you print a quoted list of strings in golang?

Published: Monday, Apr 6, 2015 Last modified: Thursday, Nov 14, 2024

This does not show leading and trailing whitespace:

log.Println(t)
2015/04/06 15:20:12 [952C9698-D2D0-41F3-93F0-36DF1549369D;08:00:27:bf:51:0c 8d0f600ff7334309b46df220dd573b6c;b8:27:eb:eb:92:83 bddb5da626430cb4bf61e236d34208;b8:27:eb:eb:92:83 ]

This does:

log.Printf("%q", t)
2015/04/06 15:20:12 ["952C9698-D2D0-41F3-93F0-36DF1549369D;08:00:27:bf:51:0c " "8d0f600ff7334309b46df220dd573b6c;b8:27:eb:eb:92:83 " "bddb5da626430cb4bf61e236d34208;b8:27:eb:eb:92:83 " ""]