title: making a general select function for sql library operations
body: <p>well i am trying to make a select function which will work like this,</p>
  
  <p>From main function i will call this select function with necessary variables. and the select function will run the query in the database and give me the reselt.</p>
  
  <p>Now for go lang if we want to do a select query for the results we need a struct where we can get the results. Since the function will be called from main func and the variables can not be predicted we cant declare a struct before hand so i am stuck here. can anyone give me a solution?</p>
  
  <p>so basically what i am trying to do is we can simply call the query like </p>
  
  <p>-- select name,phone from users where userid=1 ---
  so from the main func we will get the values like column name(name,phone), table name (users) and the condition (userid=1)</p>
  
  <p>we will pass these info to the select func and it will run the query and give us back the results.</p>
  
  <p>no matter what is the query is it should work like it. can anyone give me an sample or idea how to work with this</p>
  
  <pre class="lang-golang prettyprint-override"><code>func select() {
    //DB CONNECTION HERE
  
  type User struct {
          Name    string `json:"name"`
          Age     string `json:"age"`
          Email   string `json:"email"`
          Phone   string `json:"phone"`
          Address string `json:"address"`
      }
  
      results, err := db.Query("SELECT Name, Age, Email, Phone, Address FROM `users` where personId=12 ")
      if err != nil {
          panic(err.Error())
      }
  
      for results.Next() {
          var user User
          var email User
          var age User
          var phone User
          var address User
  
          err = results.Scan(&amp;user.Name, &amp;age.Age, &amp;email.Email, &amp;phone.Phone, &amp;address.Address)
  
          if err != nil {
              panic(err.Error())
          }
  
          fmt.Println(user.Name)
          fmt.Println(age.Age)
          fmt.Println(email.Email)
          fmt.Println(phone.Phone)
          fmt.Println(address.Address)
      }
  </code></pre>
  
  <p>Now as zou can see this is the code where we know the query so we made a struct according to it but what about the problem i described above?</p>