Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error: index out of range #264

Open
Arundas666 opened this issue Mar 27, 2024 · 1 comment
Open

runtime error: index out of range #264

Arundas666 opened this issue Mar 27, 2024 · 1 comment

Comments

@Arundas666
Copy link

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 Arundas666 changed the title Some code not working runtime error: index out of range Mar 27, 2024
@cosmos72
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants