Escape Variables with Printf

Go

Go Problem Overview


If I wanted to do the following:

fmt.Printf("Escape this -> %v... Do not escape this -> %v", "Unescaped")

How could I escape the first occurrence of %v?

\%v doesn't seem to work. Any ideas?

Go Solutions


Solution 1 - Go

You can use %% for literal %

%%	a literal percent sign; consumes no value

https://golang.org/pkg/fmt/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAri SeyhunView Question on Stackoverflow
Solution 1 - GoYOUView Answer on Stackoverflow