You didn't initialize the value of "pos" so the slice is effectively nil

On Tue, Jul 11, 2017 at 2:24 AM, Fino <xme...@gmail.com> wrote:

> https://play.golang.org/p/2Wd9xlztBr
>
>
> package main
> import (
>  "fmt"
> )
> func Fix(raw []float32, raw_prev []float32, accumulated []float32,
> threshold float32) (pos []float32) {
>  for i := 0; i < 3; i++ {
>   if raw[i]-raw_prev[i] >= threshold {
>    accumulated[i] -= 360
>   } else if raw[i]-raw_prev[i] <= -1*threshold {
>    accumulated[i] += 360
>   }
>   *pos**[**i**]* *=** raw**[**i**]* *+** accumulated**[**i**]*
>  }
>  return pos
> }
>
>
> func main() {
>  raw := make([]float32, 3, 3)
>  raw_prev := make([]float32, 3, 3)
>  accumulated := make([]float32, 3, 3)
>  pos := make([]float32, 3, 3)
>
>  pos = Fix(raw, raw_prev, accumulated, 100)
>
>  fmt.Printf("%v\n", pos)
>  fmt.Println("why we got a panic on line15 ?")
> }
>
>
>
> BR fino
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to