https://www.geeksforgeeks.org/fmt-fprintf-function-in-golang-with-examples/
在 Go 语言中,fmt 包使用类似于 C 的 printf() 和 scanf() 函数的函数实现格式化的 I/O。 Go 语言中的 fmt.Fprintf() 函数根据格式说明符格式化并写入 w。 而且,这个函数是在 fmt 包下定义的。 在这里,您需要导入“fmt”包才能使用这些功能。
In Go language, fmt package implements formatted I/O with functions analogous to C’s printf() and scanf() function. The fmt.Fprintf() function in Go language formats according to a format specifier and writes to w. Moreover, this function is defined under the fmt package. Here, you need to import the “fmt” package in order to use these functions.
// Golang program to illustrate the usage of
// fmt.Fprintf() function
// Including the main package
package main
// Importing fmt and os
import (
"fmt"
"os"
)
// Calling main
func main() {
// Declaring some const variables
const name, dept = "GeeksforGeeks", "CS"
// Calling Fprintf() function which returns
// "n" as the number of bytes written and
// "err" as any error ancountered
n, err := fmt.Fprintf(os.Stdout, "%s is a %s portal.\n",
name, dept)
// Printing the number of bytes written
fmt.Print(n, " bytes written.\n")
// Printing if any error encountered
fmt.Print(err)
}