gpt4 book ai didi

go - golang.org/x/text/message.Print 完成了什么?

转载 作者:IT王子 更新时间:2023-10-29 02:37:16 24 4
gpt4 key购买 nike

Printer.Print 的文档说:

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

但与 Printer.Printf 相比,我很难看到任何特定语言.

考虑:

package main

import (
"fmt"

"golang.org/x/text/language"
"golang.org/x/text/message"
)

func main() {
message.SetString(language.English, "foo", "bar")

p := message.NewPrinter(language.English)
p.Print("foo")
fmt.Println()
p.Printf("foo")
fmt.Println()
}

结果:

foo
bar

Printer.Print 到底做了什么(特定于语言)?

最佳答案

Package message implements formatted I/O for localized strings with functions analogous to the fmt's print functions. It is a drop-in replacement for fmt.

特定于语言的行为不会将 Printer.PrintPrinter.Printf 区分开来——而是将它们与它们的 analogous functions in the fmt package 区分开来.它就在您引用的文档中。

关于go - golang.org/x/text/message.Print 完成了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51461667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com