Skip to content

x/text/message: expected behaviour of message.Print is unclear #63173

Open
@mtibben

Description

@mtibben

What version of Go are you using (go version)?

$ go version
go version go1.21.1 darwin/arm64

$ go get golang.org/x/[email protected]

What did you do?

Executed the following https://go.dev/play/p/htbw6anb94b

message.SetString(language.German, "foo", "bar")
message.NewPrinter(language.German).Print("foo")
message.NewPrinter(language.German).Printf("foo")

What did you expect to see?

barbar

What did you see instead?

foobar

When using the Printer.Print function, I expect language substitutions to occur. If no language substitutions were wanted, I would use fmt.Print instead. I would not normally use Printf unless I am using a format specifier.

The Printer.Print documentation says

Print is like fmt.Print, but using language-specific formatting.

However it doesn't specify what types of language-specific formatting is actually applied. I'd expect string substitution to be one of these language-specific formatting.

Erroneous use of Printer.Print can also be seen on this blog post which uses Printer.Println instead of the working Printer.Printf

Is this a bug, or expected behaviour?

/cc @mpvl via https://dev.golang.org/owners

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions