title: "runtime error: invalid memory address or nil pointer dereference" creating table
body: <p>I'm getting my feet wet with Go 1.11 and postgres.</p>
  
  <pre><code>package db
  
  import (
      "database/sql"
      _ "github.com/lib/pq" //database connector
      g "app/globalvariables"
  )
  
  func CreateTable(tid int) {
  s := "CREATE TABLE someschema.sometable" + string(tid) + "(id serial PRIMARY KEY,...);"
      db, _ := sql.Open("postgres", "user="+g.DB_USER+" dbname="+g.DB_NAME+" sslmode=disable")
      defer db.Close()
      q, _ := db.Prepare(s)
      q.Exec()
  }
  </code></pre>
  
  <p>When testing the function I get:</p>
  
  <pre><code>panic: runtime error: invalid memory address or nil pointer dereference [recovered]
      panic: runtime error: invalid memory address or nil pointer dereference
  [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x51d46a]
  </code></pre>
  
  <p>What can it be?</p>