It's frequently nice to write long, informative strings for log messages or stderr messages. Python handles this with comma separated string literals, like:
log.warn("The operation failed on the %d iteration. "
"Resumed on the %d iteration.",
failed, resumed)
Go appears to have a solution for raw string literals, by using back quotes but I can't find any style guide for interpreted string literals. Am I missing something or is there no option but to use a variable? E.g.
msg := fmt.Sprintf("The operation failed on the %d iteration. ", failed)
msg += fmt.Sprintf("Resumed on the %d iteration.", resumed)
log.println(msg)
You could just use +:
fmt.Printf("The operation failed on the %d iteration. "+
"Resumed on the %d iteration.",
failed, resumed,
)
Playground.
There are examples in the standard library of using + for that, most of them in tests. Example. For more examples see this search request: http://golang.org/search?q=%22\%2B\n.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With