title: Gorm Golang orm associations
body: <p>I'm using Go with the <a href="https://github.com/jinzhu/gorm">GORM ORM</a>.
  I have the following structs. The relation is simple. One Town has multiple Places and one Place belongs to one Town.</p>
  
  <pre><code>type Place struct {
    ID          int
    Name        string
    Town        Town
  }
  
  type Town struct {
    ID   int
    Name string
  }
  </code></pre>
  
  <p>Now i want to query all places and get along with all their fields the info of the corresponding town.
  This is my code:</p>
  
  <pre><code>db, _ := gorm.Open("sqlite3", "./data.db")
  defer db.Close()
  
  places := []Place{}
  db.Find(&amp;places)
  fmt.Println(places)
  </code></pre>
  
  <p>My sample database has this data:</p>
  
  <pre><code>/* places table */
  id  name    town_id
   1  Place1        1
   2  Place2        1
  
  /* towns Table */
  id name
   1 Town1
   2 Town2
  </code></pre>
  
  <p>i'm <strong>receiving</strong> this: </p>
  
  <p><code>[{1 Place1 {0 }} {2 Mares Place2 {0 }}]</code></p>
  
  <p>But i'm <strong>expecting</strong> to receive something like this (both places belongs to the same town): </p>
  
  <p><code>[{1 Place1 {1 Town1}} {2 Mares Place2 {1 Town1}}]</code></p>
  
  <p>How can i do such query ? I tried using <code>Preloads</code> and <code>Related</code> without success (probably the wrong way). I can't get working the expected result.</p>