title: How to return an array more efficiently
body: <p>My requirements is to have a function to return an array efficiently. </p>
  
  <p>As I know, array is value type, so when passing in/out array to a function, it does <code>copy</code>. Therefore, I am thinking return pointer of array. People will recommend using slice, but by using slice, I still need <code>copy</code> to transfer to array. </p>
  
  <p><a href="https://play.golang.org/p/-CZ6_zvh6rG" rel="nofollow noreferrer">This</a> is the playground contains both solutions, please suggest if it is right way to go to return pointer of array, thanks.</p>
  
  <pre><code>package main
  
  import (
   "fmt"
  )
  
  type geo [2]float32
  
  func genArray () geo {
    ret := geo{1.2, 2.3}
    return ret
  }
  
  func genPointerOfArray () *geo {
    ret := geo{1.2, 2.3}
    return &amp;ret
  }
  
  
  func main() {
    ret1 := genArray()
    ret2 := *genPointerOfArray()
    fmt.Println(ret1, ret2)
  }
  </code></pre>