title: initializing a struct containing a slice of structs in golang
body: <p>I have a struct that I want to initialize with a slice of structs in golang, but I'm trying to figure out if there is a more efficient version of appending every newly generated struct to the slice:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "math/rand"
  )
  
  type LuckyNumber struct {
      number int
  }
  
  type Person struct {
      lucky_numbers []LuckyNumber
  }
  
  func main() {
      count_of_lucky_nums := 10
      // START OF SECTION I WANT TO OPTIMIZE
      var tmp []LuckyNumber
      for i := 0; i &lt; count_of_lucky_nums; i++ {
          tmp = append(tmp, LuckyNumber{rand.Intn(100)})
      }
      a := Person{tmp}
      // END OF SECTION I WANT TO OPTIMIZE
      fmt.Println(a)
  }
  </code></pre>