gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

README.md (924B)


      1 # go-debug
      2 
      3 This library provides a very simple method for compile-time or runtime determined debug checks, set using build tags.
      4 
      5 The compile-time checks use Go constants, so when disabled your debug code will not be compiled.
      6 
      7 The possible build tags are:
      8 
      9 - "debug" || "" = debug determined at compile-time
     10 
     11 - "debugenv" = debug determined at runtime using the $DEBUG environment variable
     12 
     13 An example for how this works in practice can be seen by the following code:
     14 
     15 ```
     16 func main() {
     17 	println("debug.DEBUG() =", debug.DEBUG())
     18 }
     19 ```
     20 
     21 ```
     22 # Debug determined at compile-time, it is disabled
     23 $ go run .
     24 debug.DEBUG() = false
     25 
     26 # Debug determined at compile-time, it is enabled
     27 $ go run -tags=debug .
     28 debug.DEBUG() = true
     29 
     30 # Debug determined at runtime, $DEBUG is not set
     31 $ go run -tags=debugenv .
     32 debug.DEBUG() = false
     33 
     34 # Debug determined at runtime, $DEBUG is set
     35 $ DEBUG=y go run -tags=debugenv .
     36 debug.DEBUG() = true
     37 ```