1. 11
  1.  

  2. 2

    That does sound annoying. I guess you’re effectively forced to locally wrap fmt.Print(m) with Debug(m) that calls fmt.Print(m) if you want to avoid the hassle.

    1. 1

      I’ve run into it in C before with certain compiler flags that complain about unused variables. I’d just wrap the code in an if (0) {} rather than commenting it out so it’s is still there according to the compiler, but it just never runs. Then once you’re done debugging, rip out the whole block.

      1. 1

        I’ve seen people use preprocessor conditionals in the same way, which I guess has the added advantage of not getting compiled at all.

        Example:

        #if 0
        ...code...
        #endif
        
        1. 1

          Yeah but then you still have variable declarations and (in Go’s case, includes) that will still be there when the preprocessor rips out all of the code between #if/#endif.

          1. 1

            Ah, I see. I misunderstood your original comment. Neat trick.