title: Golang panic: runtime error: index out of range
body: <p>This function takes an array with some integers and my goal is to have a new array with just positive integers:</p>
  <pre><code>func domath(newarray[] int, i int, array[] int)([]int){
      if i &lt; len(newarray) {
          if newarray[i] &lt; 0{
              i ++    
              domath(newarray, i, array)
          }
          if newarray[i] &gt;= 0 {
              array = append(array, newarray[i])
              i ++
              domath(newarray, i, array)
          }
      }
      return array 
  }
  </code></pre>
  <p>However, I keep getting the same error saying panic:</p>
  <blockquote>
  <p>runtime error: index out of range</p>
  </blockquote>