github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/zdebug/zdebug.go (about) 1 package zdebug 2 3 import ( 4 "fmt" 5 "path/filepath" 6 "runtime" 7 "time" 8 ) 9 10 // PrintTrace 是否开启trace 11 var PrintTrace = true 12 13 // T 调试输出,可以把printTrace改为false关闭输出 14 func T(format string, args ...interface{}) { 15 if !PrintTrace { 16 return 17 } 18 _, file1, line1, _ := runtime.Caller(1) 19 file1 = filepath.Base(file1) 20 x := time.Now().Format("[15:04:05]") 21 prefix := fmt.Sprintf("[\033[41m%v\033[0m \033[32m%v:%v\033[0m ] ", x, file1, line1) 22 fmt.Printf(prefix+format+"\n", args...) 23 }