利用Go1.4的新特性,在go test时输出glog日志
来源:互联网 发布:智能手环功能原理 知乎 编辑:程序博客网 时间:2024/04/28 00:13
Go1.4 新增了一个功能:TestMain(m *testing.M)
利用这个函数,可以在*_test.go里面统一设置一次glog的参数,让go test的输出,也能包含glog的日志!
func TestMain(m *testing.M) {flag.Set("alsologtostderr", "true")flag.Set("log_dir", "/tmp")flag.Set("v", "3")flag.Parse()ret := m.Run()os.Exit(ret)}
这样可以避免在每个TestXXX函数的开头都去设置flag.
参考:
https://justinas.org/my-reason-to-be-excited-for-go-14/
https://www.andyjeffries.co.uk/25-tips-for-intermediate-git-users/
0 0
- 利用Go1.4的新特性,在go test时输出glog日志
- Go1.3新特性 栈的全新实现—连续栈(4)
- 剖析Go1.3新特性:sync.Pool
- Go1.3新特性 栈的全新实现—连续栈(1)
- Go1.3新特性 栈的全新实现—连续栈(2)
- Go1.3新特性 栈的全新实现—连续栈(3)
- Go语言 Go1.1新调度器详解
- Go语言 Go1.1新调度器详解
- google的glog日志管理
- 修改glog源码解决不同级别日志混合输出的问题
- Oracle 12c 新特性---password expired 的用户会输出到alert日志中
- glog多线程下按照指定条件创建新的日志文件
- 在node中集成glog日志系统
- 如何使用google的日志库(glog)
- JDK1.5新特性之二----新的格式化输出
- 源码编译安装go,ERROR: Cannot find /root/go1.4/bin/go
- assert 是在 J2SE1.4 中引入的新特性
- 在VS2015下,glog的简单使用
- java容器
- 需要熟悉的数学库中的一些函数
- 证券市场参与者笔记
- android之activity横竖屏切换时的生命周期以及横竖屏切换时的资源适配方案
- iOS8 SDK中部份更新
- 利用Go1.4的新特性,在go test时输出glog日志
- JS Canvas Snaps
- 1079. Total Sales of Supply Chain (25)
- Mac下Node.js 环境搭建
- 关于java的trim
- Activity传递参数到Fragment
- MFC 中 CFile、CStdioFile、CFileDialog 的用法
- 数据结构课程设计
- JAVA学习笔记1——引言+数值类型