Skip to content

Get and similar functions don't always process formatting sequences #57

@bk2204

Description

@bk2204

Please describe your issue

Is this a bug, an improvement, a proposal or something else? Describe it.

This is a bug.

The Printf function used to format strings doesn't always invoke fmt.Sprintf. As a result, the expansion of %% sequences differs if there are arguments or not.

What's the expected behaviour, the current behaviour and the steps to reproduce it?

I expect that I can create a locale object, tr, and then do this:

a := tr.Get("My string with an escaped value: %%s")
fmt.Printf(a, "text")

And that it prints My string with an escaped value: text. I happen to need this because I have a map of integers to format strings, where the format strings contain %% sequences.

Unfortunately, the behavior is inconsistent, so things are only passed through fmt.Sprintf if there are arguments. This makes the behavior hard to reason about.

Comments

If there were separate functions to read strings that were formatted and ones that were not, this wouldn't be a problem.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions