package
Version:
v0.0.1
Opens a new window with list of versions in this module.
Published: Feb 25, 2025
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package testing 提供了一组用于测试时输出日志的辅助函数。
这个包封装了标准库 fmt 包的功能,并在输出内容前添加统一的日志前缀,
使测试输出更加清晰和易于识别。
func Printf(format string, a ...interface{})
Printf 函数用于输出带有统一前缀的格式化日志信息。
该函数会在实际内容前添加 logHeader 前缀,并根据提供的格式字符串格式化输出内容。
参数:
- format string:格式化字符串,支持所有 fmt.Printf 的格式化指令。
- a ...interface{}:要格式化输出的参数列表。
使用示例:
testing.Printf("当前进度:%d%%\n", 50)
testing.Printf("用户:%s,年龄:%d\n", "张三", 25)
func Println(a ...interface{})
Println 函数用于输出带有统一前缀的日志信息,并在末尾自动添加换行符。
该函数会在实际内容前添加 logHeader 前缀,并使用空格分隔多个参数。
参数:
- a ...interface{}:要输出的任意类型参数列表,支持多个参数。
使用示例:
testing.Println("测试信息")
testing.Println("值:", 100, "状态:", "成功")
Source Files
¶
Click to show internal directories.
Click to hide internal directories.