gophernotes icon indicating copy to clipboard operation
gophernotes copied to clipboard

runtime error: index out of range

Open Arundas666 opened this issue 1 year ago • 1 comments

package main

import ( "fmt" )

func fibonacci(n int, c chan int) { x, y := 0, 1 for i := 0; i < n; i++ { c <- x x, y = y, x+y } close(c) }

func main() { c := make(chan int, 10) go fibonacci(cap(c), c) for i := range c { fmt.Println(i) } }, This is not working in gophernotes, can anyone explain why?

Arundas666 avatar Mar 27 '24 12:03 Arundas666

Hi @Arundas666,

I tried to reproduce your issue, but it works as expected for me. Note: main() is not special in gophernotes, so it must be called explicitly.

image

cosmos72 avatar Mar 28 '24 20:03 cosmos72