Ari Seyhun
Ari Seyhun

Reputation: 12521

Escape Variables with Printf

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?

Upvotes: 78

Views: 52820

Answers (1)

YOU
YOU

Reputation: 123831

You can use %% for literal %

%%  a literal percent sign; consumes no value

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

Upvotes: 154

Related Questions