"pos" is not initialized. You think you are using the *global* var "pos", but you are wrong as it's been *overwritten* by the *named return var *"pos" (defined like this (pos []float32)).
On Tuesday, July 11, 2017 at 5:24:19 PM UTC+8, Fino 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.