I'm a complete beginner in go. And I just installed gophernotes and intend to use Jupyter Notebook for main programming.
This program gives the following error when run in Jupyter:
Cell1: package main
Out1: runtime error: index out of range
Cell2: import "fmt"
func main() {
fmt.Println("hello world")
}
main()
Out2: hello world
When I write the same in a test.go
and execute from bash: go run test.go
, I get the following:
Deepaks-MacBook-Air:JUPYTER deepak$ go run test.go
go: disabling cache (/Users/deepak/Library/Caches/go-build) due to initialization failure: open /Users/deepak/Library/Caches/go-build/log.txt: permission denied
# command-line-arguments
./test.go:6:1: syntax error: non-declaration statement outside function body