Closed animesh closed 7 years ago
Hi @animesh. Sorry for the delay here. In gophernotes, you don't have to specify a package or function main. Just paste your various pieces of code into the notebook and go for it. That is, you can just past the following into respective cells:
import "time"
import "fmt"
import "math/rand"
// For example, `rand.Intn` returns a random `int` n,
// `0 <= n < 100`.
fmt.Print(rand.Intn(100), ",")
fmt.Print(rand.Intn(100))
fmt.Println()
// `rand.Float64` returns a `float64` `f`,
// `0.0 <= f < 1.0`.
fmt.Println(rand.Float64())
etc...
Let me know if you have any issues with this strategy.
Thanks Daniel for looking into this :+1:
@dwhitena , error has disappeared, but i don't see any output though...
below is my system
uname -a
Linux animeshs-Latitude-E6230 4.10.0-20-generic #22-Ubuntu SMP Thu Apr 20 09:22:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
and the kernel configuration
cat .local/share/jupyter/kernels/gophernotes/kernel.json
{
"argv": [
"gophernotes",
"{connection_file}"
],
"display_name": "Go",
"language": "go",
"name": "go"
}
any ideas what could be the issue?
@animesh can you provide the exact code you are running in the notebook cell?
import "time" import "fmt" import "math/rand" fmt.Print(rand.Intn(100), ",") fmt.Print(rand.Intn(100)) fmt.Println() fmt.Println(rand.Float64())
Hmmm... Sorry you are experiencing this. This is what I get:
Maybe you are using an old release of gophernotes? Do you know what version?
@dwhitena thanks for tip regarding version, i am not sure what worked, but reinstalling makes it work, sort of :+1: the issue now i am facing is that some sort of accumulation is going on when i call the cell again. For example, a run with code similar to your cell-2 gives
81,8747,5981,1825,40456,0694,1162,9728,4211,5237,6495,6528,847,7287,8790,5541,8387,1429,6737,1485,6413,0194,3433,778,4159,3957,1189,90,5888,8703,5451,0605,6266,8561,2783,6563,62,8447,4577,3996,023,5337,3341,5933,4391,278,3646,740,352,435,9825,5115,5787,3
<nil>
102
<nil>
1
<nil>
0.0005138155161213613
22
<nil>
while re-run of the same cell gives
81,8747,5981,1825,40456,0694,1162,9728,4211,5237,6495,6528,847,7287,8790,5541,8387,1429,6737,1485,6413,0194,3433,778,4159,3957,1189,90,5888,8703,5451,0605,6266,8561,2783,6563,62,8447,4577,3996,023,5337,3341,5933,4391,278,3646,740,352,435,9825,5115,5787,1010,3
<nil>
852
<nil>
1
<nil>
0.39998376285699544
20
<nil>
any ideas what is going on?
@animesh I think this is the expected behavior. Closing for now.
Basically, when you rerun the cell, you are seeing new random numbers being generated. Also, you can try this in v1 (RC just released). It should behave as expected. Please follow up here if you see otherwise.
@dwhitena :+1: works nice, thx :)
facing "expected declaration, found 'package' " error while trying to run https://play.golang.org/p/ZdFpbahgC1 :
code runs fine via 'go run' command line, any ideas on how to get around this?