Skip to content

Commit

Permalink
添加一个debug用的print方法
Browse files Browse the repository at this point in the history
  • Loading branch information
pangwu86 committed Sep 9, 2013
1 parent 3917408 commit c347bf2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions debug.go
@@ -0,0 +1,41 @@
package z

import (
"fmt"
)

// 给一个总开关, 这样在调试的时候就可以使用总开关关闭打印语句了
var _print_on_ bool = false

func IsDebugOn() bool {
return _print_on_
}

func DebugOn() {
_print_on_ = true
}

func DebugOff() {
_print_on_ = false
}

func DebugPrint(a ...interface{}) (n int, err error) {
if _print_on_ {
return fmt.Print(a...)
}
return 0, nil
}

func DebugPrintf(format string, a ...interface{}) (n int, err error) {
if _print_on_ {
return fmt.Printf(format, a...)
}
return 0, nil
}

func DebugPrintln(a ...interface{}) (n int, err error) {
if _print_on_ {
return fmt.Println(a...)
}
return 0, nil
}
2 changes: 1 addition & 1 deletion nums.go
Expand Up @@ -22,5 +22,5 @@ func IndexOfStrings(array []string, one string) int {

// 判断字符串是否在数组中
func IsInStrings(array []string, one string) bool {
return IndexOfStrings(array, one) > 0
return IndexOfStrings(array, one) > -1
}

0 comments on commit c347bf2

Please sign in to comment.