title: Non-declaration statement outside function body in Go
body: <p>I'm building a Go library for an API that offers JSON or XML formatted data.</p>
  
  <p>This API requires me to request a <code>session_id</code> every 15 minutes or so, and use that in calls. For example:</p>
  
  <pre><code>foo.com/api/[my-application-id]/getuserprofilejson/[username]/[session-id]
  foo.com/api/[my-application-id]/getuserprofilexml/[username]/[session-id]
  </code></pre>
  
  <p>In my Go library, I'm trying to create a variable outside of the <code>main()</code> func and intend to ping it for a value for every API call. If that value is nil or empty, request a new session id and so on.</p>
  
  <pre><code>package apitest
  
  import (
      "fmt"
  )
  
  test := "This is a test."
  
  func main() {
      fmt.Println(test)
      test = "Another value"
      fmt.Println(test)
  
  }
  </code></pre>
  
  <p>What is the idiomatic Go way to declare a globally-accessible variable, but not necesarilly a constant? </p>
  
  <p>My <code>test</code> variable needs to:</p>
  
  <ul>
  <li>Be accessible from anywhere within it's own package.</li>
  <li>Be changeable</li>
  </ul>