LoginSignup
4
4

More than 5 years have passed since last update.

Go言語でdebugログの実現方法

Posted at

標準ライブラリをのぞいていたらdebugログを下記の様に実装してたので備忘録までに・・・

var debug = debugT(false)
type debugT bool
func (d debugT) Printf(format string, args ...interface{}) {
      if d {
            log.Printf(format, args...)
      }
}

って感じで定義しといて使うときには

debug.Printf("hogehoge: %s", s)
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4