- 新增 Printfln 函数用于格式化打印 - 定义 Product 和 Customer 结构体类型 - 实现 printDetails1 支持不同类型元素打印 - 实现 printDetails2 使用反射打印结构体字段 - 添加 Payment 结构体用于测试反射打印- 初始化 go.mod 模块配置文件
8 lines
124 B
Go
8 lines
124 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func Printfln(template string, values ...interface{}) {
|
|
fmt.Printf(template+"\n", values...)
|
|
}
|