title: Settings global conditional variables in Go
body: <p>I want to parse and set a variable conditionally in Go at the global package level based on the value of of an ENV var, so that I don't have to check for it every time in a utility function (as the variable would be declared once at run time). For example, what I want to accomplish is (Go pseudo-code):</p>
  
  <pre><code>import (
      "fmt"
      "os"
      "strconv"
  )
  
  // This works to read the value of MYVAR (=true/false)
  var myvar string = os.Getenv("MYVAR")
  
  // Apparently this is too much for Go
  var myvarbool, _ = strconv.ParseBool(myvar)
  
  // Utility function to check for value
  func mycheck() {
      if myvarbool {
          fmt.Print("MYVAR is true")
      }
  }
  </code></pre>
  
  <p>This is a library package, so doesn't have a main() function to do this kind of setup, but I want to be able to use mycheck() in other functions in the library, and don't want to have to read and parse MYVAR every time mycheck() is called.</p>