title: How to properly use build tags?
body: <p>I need to be able to build different versions of a go application; a 'debug' version and a normal version.</p>
  <p>This is easy to do; I simply have a const DEBUG, that controls the behaviour of the application, but it's annoying to have to edit the config file every time I need to swap between build types.</p>
  <p>I was reading about go build (<a href="http://golang.org/pkg/go/build/" rel="nofollow noreferrer">http://golang.org/pkg/go/build/</a>) and tags, I thought perhaps I could do this:</p>
  <p>config.go:</p>
  <pre><code>// +build !debug
  package build
  const DEBUG = false
  </code></pre>
  <p>config.debug.go:</p>
  <pre><code>// +build debug
  package build
  const DEBUG = true
  </code></pre>
  <p>Then I should be able to build using <code>go build</code> or <code>go build -tags debug</code>, and the tags should exclude <code>config.go</code> and include <code>config.debug.go</code>.</p>
  <p>...but this doesn't work. I get:</p>
  <blockquote>
  <p>src/build/config.go:3: DEBUG redeclared in this block (&lt;0&gt;) previous
  declaration at src/build/config.debug.go:3</p>
  </blockquote>
  <p>What am I doing wrong?</p>
  <p>Is there another and more appropriate #ifdef style way of doing this I should be using?</p>