Giter Club home page Giter Club logo

lgo's Introduction

lgo Binder Go Report Card

Go (golang) Jupyter Notebook kernel and an interactive REPL

Disclaimer

Since go1.10, this Go kernel has performance issue due to a performance regression in Go tool chain.

Also, this Go kernel can not be built with go1.12 due to another regression in Go tool chain.

Now, the compiler options this kernel relies on are completely broken and I'm not sure when they will fix the regressions. Unfortunately, they don't plan to fix this in go1.13 as of July 8th 2019. If you are interested in using this kernel, please upvote the bugs. For a while, please use other Go kernels if you want to use the later version of Go with Jupyter notebook.

Medium Post

Features

  • Write and execute Go (golang) interactively like Python.
  • Jupyter Notebook integration
  • Full Go (golang) language spec support. 100% gc (go compiler) compatible.
  • Code completion and inspection in Jupyter Notebooks
  • Display images, HTML, JavaScript, SVG, etc...
  • Currently, lgo is only supported on Linux. But you can use lgo on Mac and Windows with virtual machines or Docker.

Jupyter notebook examples

You can view example notebooks of lgo from Example notebooks on Jupyter nbviewer

If you want to execute these notebooks, you can try these notebooks on your browser without installation from Binder

Try lgo from your browser without installation

Binder

Thanks to binder (mybinder.org), you can try lgo on your browsers with temporary docker containers on binder. Open your temporary Jupyter Notebook from the button above and enjoy lgo.

Quick Start with Docker

  1. Install Docker and Docker Compose.
  2. Clone the respository and run the docker container with docker-compose.
> git clone https://github.com/yunabe/lgo.git
> cd lgo/docker/jupyter
> docker-compose up -d

If you want to use a port other than 8888 on host, update ports config in lgo/docker/jupyter/docker-compose.yaml before running docker-compose up.

  1. Get the URL to open the Jupyter Notebook
> docker-compose exec jupyter jupyter notebook list
Currently running servers:
http://0.0.0.0:8888/?token=50dfee7e328bf86e70c234a2f06021e1df63a19641c86676 :: /examples
  1. Open the Jupyter Notebook server with the authentication token above.

Linux/Mac OS

If you are using Linux or Mac OS, you can use start/stop scripts instead. Web browser will open the URL automatically.

# start server
> ./up.sh
# stop server
> ./down.sh

Install

Prerequisites

Install

  • go get github.com/yunabe/lgo/cmd/lgo && go get -d github.com/yunabe/lgo/cmd/lgo-internal
    • This installs lgo command into your $(go env GOPATH)/bin
  • Set LGOPATH environment variable
    • lgo install will install binaries into the directory specified with LGOPATH.
    • You can use any empty directory with write permission as LGOPATH.
  • Run lgo install
    • This installs std libraries and the internal lgo tool into LGOPATH with specific compiler flags.
    • If lgo install fails, please check install log stored in $LGOPATH/install.log
  • (Optional) Run lgo installpkg [packages] to install third-party packages to LGOPATH
    • You can preinstall third-party packages into LGOPATH.
    • This step is optional. If packages are not preinstalled, lgo installs the packages on the fly.
    • But, installing packages is a heavy and slow process. I recommend you to preinstall packages which you will use in the future with high probability.
    • If lgo installpkg fails, please check the log stored in $LGOPATH/installpkg.log.
    • See go's manual about the format of [packages] args.
  • Install the kernel configuration to Jupyter Notebook
    • python $(go env GOPATH)/src/github.com/yunabe/lgo/bin/install_kernel
    • Make sure to use the same version of python as you used to install jupyter. For example, use python3 instead of python if you install jupyter with pip3.
  • (Optional) If you want to use lgo with JupyterLab, install a jupyterlab extension for lgo
    • jupyter labextension install @yunabe/lgo_extension
    • This extension adds "Go Format" button to the toolbar in JupyterLab.

Usage: Jupyter Notebook

  • Run jupyter notebook command to start Juyputer Notebook and select "Go (lgo)" from New Notebook menu.
  • To show documents of packages, functions and variables in your code, move the cursor to the identifier you want to inspect and press Shift-Tab.
  • Press Tab to complete code
  • Click Format Go button in the toolbar to format code.
  • lgo works with JupyterLab. To use lgo from JupyterLab, install JupyterLab and run jupyter lab.

Usage: REPL console

You can use lgo from command line with Jupyter Console or build-in REPL mode of lgo

Jupyter Console (Recommended)

Run jupyter console --kernel lgo

In [1]: a, b := 3, 4

In [2]: func sum(x, y int) int {
      :     return x + y
      :     }

In [3]: import "fmt"

In [4]: fmt.Sprintf("sum(%d, %d) = %d", a, b, sum(a, b))
sum(3, 4) = 7

built-in REPL mode

Run lgo run

$ lgo run
>>> a, b := 3, 4
>>> func sum(x, y int) int {
...     return x + y
...     }
>>> import "fmt"
>>> fmt.Sprintf("sum(%d, %d) = %d", a, b, sum(a, b))
sum(3, 4) = 7

Tips

go get and lgo

The packages you want to use in lgo must be prebuilt and installed into $LGOPATH by lgo install command. Please make sure to run lgo install after you fetch a new package with go get command.

Update go version

Please run lgo install --clean after you update go version.

lgo install installs prebuilt packages into $LGOPATH. When you update go version, you need to reinstall these prebuilt packages with the newer go because binary formats of prebuilt packages may change in the newer version of go.

Display HTML and images

To display HTML and images in lgo, use _ctx.Display. See the example of _ctx.Display in an example notebook

Cancellation

In lgo, you can interrupt execution by pressing "Stop" button (or pressing I, I) in Jupyter Notebook and pressing Ctrl-C in the interactive shell.

However, as you may know, Go does not allow you to cancel running goroutines with Ctrl-C. Go does not provide any API to cancel specific goroutines. The standard way to handle cancellation in Go today is to use context.Context (Read Go Concurrency Patterns: Context if you are not familiar with context.Context in Go).

lgo creates a special context _ctx on every execution and _ctx is cancelled when the execution is cancelled. Please pass _ctx as a context.Context param of Go libraries you want to cancel. Here is an example notebook of cancellation in lgo.

Memory Management

In lgo, memory is managed by the garbage collector of Go. Memory not referenced from any variables or goroutines is collected and released automatically.

One caveat of memory management in lgo is that memory referenced from global variables are not released automatically when the global variables are shadowed by other global variables with the same names. For example, if you run the following code blocks, the 32MB RAM reserved in [1] is not released after executing [2] and [3] because

  • [2] does not reset the value of b in [1]. It just defines another global variable b with the same name and shadows the reference to the first b.
  • [3] resets b defined in [2]. The memory reserved in [2] will be released after [3]. But the memory reserved in [1] will not be released.
[1]
// Assign 32MB ram to b.
b := make([]byte, 1 << 25)
[2]
// This shadows the first b.
b := make([]byte, 1 << 24)
[3]
// This sets nil to the second b.
b = nil

go1.10

lgo works with go1.10. But the overhead of code execution is 4-5x larger in go1.10 than go1.9. It is due to a regression of the cache mechnism of go install in go1.10. I recommend you to use lgo with go1.9 until the bug is fixed in go1.10.

Comparisons with similar projects

gore

gore, which was released in Feb 2015, is the most famous REPL implementation for Go as of Dec 2017. gore is a great tool to try out very short code snippets in REPL style.

But gore does not fit to data science or heavy data processing at all. gore executes your inputs by concatinating all of your inputs, wrapping it with main function and running it with go run command. This means every time you input your code, gore executes all your inputs from the begining. For example, if you are writing something like

  1. Loads a very large CSV file as an input. It takes 1 min to load.
  2. Analyzes the loaded data. For example, calculates max, min, avg, etc..

gore always runs the first step when you calculate something and you need to wait for 1 min every time. This behavior is not acceptable for real data science works. Also, gore is not good at tyring code with side effects (even fmt.Println) because code snippets with side effects are executed repeatedly and repeatedly. lgo chose a totally different approach to execute Go code interactively and does not have the same shortcoming.

gore is a CLI tool and it does not support Jupyter Notebook.

gophernotes

lgo gophernotes
Backend gc (go compiler) An unofficial interpreter
Full Go Language Specs ✔️
100% gc compatible ✔️
Static typing ✔️ to some extent
Performance Fast Slow
Overhead 500ms 1ms
Cancellation ✔️
Code completion ✔️
Code inspection ✔️
Code formatting ✔️
Display HTML and images ✔️
Windows, Mac Use Docker or VM Partial
License BSD LGPL

gophernotes was the first Jupyter kernel for Go, released in Jan 2016. Before Sep 2017, it used the same technology gore uses to evaluate Go code. This means it did not fit to heavy data processing or data analysis at all. From Sep 2017, gophernotes switched from go run approach to gomacro, one of unofficial golang interpreters by cosmos72. This solved the problem gore has. Now, the code execution mechnism of gophernotes also fits to heavy data analysis.

The shortcomings of using an unofficial interpreter are

  • It does not support all Go language features. Especially, it does not support one of the most important Go feature, interface. As of go1.10, it is hard to support interface in an interpreter written in Go because of the lack of API in reflect package.
  • Interpreters are generally slow.
  • Unofficial interpreters are not well-tested compared to the official gc (go compiler) tools.

The advantages of this approach are

  • The overhead of code execution is small because it does not compile and link code.
  • Windows/Mac partial support. lgo works only on Linux and you need to use VMs or Docker to run it on Windows/Mac. gophernotes (gomacro) works on Windows/Mac natively if you do not need third-party packages.

These disadvantage and advantages are not something inevitable in interperters. But they are not easy to solve under the limited development resource.

Also, lgo kernel supports more rich features in Jupyter Notebook as of Dec 2017, including code completion, code inspection and images/HTML/JavaScript output supports.

Troubleshooting

Dead kernel

Symptom

Got an error message like:

Kernel Restarting
The kernel appears to have died. It will restart automatically.

Solutions

First, please confirm your code does not call os.Exit directly or indirectly. In lgo, your code is executed in the processs of lgo kernel. If you evaluate os.Exit in lgo, it terminates the lgo kernel process and jupyter notebook server loses the connection with the kernel. Thus, you must not evaluate os.Exit or functions that call it internally (e.g. log.Fatal) in lgo.

If os.Exit is not the reason of "Dead kernel", please check crash logs of the kernel. If you run your notebook with jupyter notebook command in a terminal, the crash log should be there. If you run your notebook in docker, attach the container's terminal with docker attach to view the logs. If you can see the logs of jupyter notebook, you should see logs like

2018/03/01 20:30:45 lgo-internal failed: exit status 1
[I 22:34:00.500 NotebookApp] KernelRestarter: restarting kernel (1/5)
kernel abcd1234-5678-efghi-xxxx-777eeffcccbb restarted

and you can probably see helpful information before lgo-internal failed message.

multiple roots

Sympton

Got an error message like:

multiple roots $LGOPATH/pkg &
Failed to build a shared library of github.com/yunabe/lgo/sess7b..7d/exec1: exit status 1

Solutions

This error occurs when the go command you are currently using is different from the go command you used to run lgo install. For example, this happens if you update go from 1.9 to 1.10 but did not run lgo install --clean with the new go after the update.

If you encouter this issue, please double-check that you are using go which you used to run lgo install to install packages into $LGOPATH.

old export format no longer supported

Symptom

Got error messages like:

could not import github.com/yunabe/mylib (/home/yunabe/local/gocode/pkg/linux_amd64/github.com/yunabe/mylib.a: import "github.com/yunabe/mylib": old export format no longer supported (recompile library))

Reason and Solution

Some libraries installed in your $GOPATH are in the old format, which are built go1.6 or before. Make sure all libraries under your $GOPATH are recompiled with your current go compiler.

cd $GOPATH/src; go install ./...

lgo's People

Contributors

cprieto avatar ibrasho avatar innovativeinventor avatar raghavendranagaraj-grabtaxi avatar yazgazan avatar yunabe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lgo's Issues

Trying to install Kubernetes client-go package fails

Hi, and thanks for the awesome project!

I'm trying to install the Kubernetes client-go so I can use it in a notebook. This is what I'm trying to do in the Dockerfile:

RUN go get k8s.io/client-go/...

RUN go get github.com/tools/godep

RUN cd /go/src/k8s.io/client-go && godep restore
RUN lgo installpkg k8s.io/client-go/...

While most of the packages seem to be installed correctly, some of them fail in the following way:

 /tmp/go-build734525261/libk8s.io-client-go-tools-portforward.so
k8s.io/apimachinery/pkg/apis/meta/v1.ParseToLabelSelector: missing section for relocation target k8s.io/apimachinery/pkg/util/sets.String.PopAny
k8s.io/apimachinery/pkg/apis/meta/v1.ParseToLabelSelector: reloc 8 to non-elf symbol k8s.io/apimachinery/pkg/util/sets.String.PopAny (outer=k8s.io/apimachinery/pkg/util/sets.String.PopAny) 0
k8s.io/apimachinery/pkg/apis/meta/v1.ParseToLabelSelector: undefined: "k8s.io/apimachinery/pkg/util/sets.String.PopAny"
(336/348) failed to install "k8s.io/client-go/tools/portforward": exit status 2
# /tmp/go-build519294519/libk8s.io-apimachinery-pkg-util-remotecommand.so
k8s.io/apimachinery/pkg/apis/meta/v1.ParseToLabelSelector: missing section for relocation target k8s.io/apimachinery/pkg/util/sets.String.PopAny
k8s.io/apimachinery/pkg/apis/meta/v1.ParseToLabelSelector: reloc 8 to non-elf symbol k8s.io/apimachinery/pkg/util/sets.String.PopAny (outer=k8s.io/apimachinery/pkg/util/sets.String.PopAny) 0
k8s.io/apimachinery/pkg/apis/meta/v1.ParseToLabelSelector: undefined: "k8s.io/apimachinery/pkg/util/sets.String.PopAny"

Although it seems to be an issue with the package itself, I want to make sure that:

 reloc 8 to non-elf symbol 
 missing section for relocation target 

are not issues with the compatibility of this project.

Thanks!

Runtime panic has occurred using switch statement without a condition

ISSUE TYPE:

  • Bug Report

OS / ENVIRONMENT:

  • Ubuntu 16.04.3 LTS (Xenial Xerus)
  • go version go1.9.2 linux/amd64
  • jupyter v4.3.0
  • libzmq3-dev/xenial,now 4.1.4-7 amd64 [installed]

SUMMARY:

When I wrote switch statement without a condition on code block in lgo notebook, runtime panic has occurred.

STEPS TO REPRODUCE:

  1. Run the following code on lgo code block:
import (
    "fmt"
)

n := 4
switch {
case n > 0 && n < 3:
    fmt.Println("0 < n < 3")
case n > 3 && n < 6:
    fmt.Println("3 < n < 6")
}

EXPECTED RESULTS:

Get the following output:

3 < n < 6

ACTUAL RESULTS:

panic: ast.Walk: unexpected node type <nil>

goroutine 24 [running]:
runtime/debug.Stack(0xc420afc8d0, 0x7f3b6a036000, 0xc420124650)
	/usr/lib/go-1.9/src/runtime/debug/stack.go:24 +0xa9
main.(*handlers).HandleExecuteRequest.func3.1()
	/home/ubuntu/go/src/github.com/yunabe/lgo/cmd/lgo-internal/kernel.go:161 +0x70
panic(0x7f3b6a036000, 0xc420124650)
	/usr/lib/go-1.9/src/runtime/panic.go:491 +0x294
go/ast.Walk(0x7e5fc0, 0xc420128b59, 0x0, 0x0)
	/usr/lib/go-1.9/src/go/ast/walk.go:364 +0x3144
github.com/yunabe/lgo/converter.containsCall(0x0, 0x0, 0x0)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:23 +0x8f
github.com/yunabe/lgo/converter.isHeavyStmt(0x7e7f00, 0xc4200a45d0, 0xc420124610)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:87 +0x11e
github.com/yunabe/lgo/converter.injectAutoExitToStmt(0x7e7f00, 0xc4200a45d0, 0xc420124610, 0xc42039e801, 0x0)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:176 +0x3b
github.com/yunabe/lgo/converter.injectAutoExitToBlockStmtList(0xc4200a4638, 0x7e0001, 0xc420124610)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:163 +0x41c
github.com/yunabe/lgo/converter.injectAutoExitBlock(0xc4200a4630, 0x1, 0xc420124610)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:104 +0x4f
github.com/yunabe/lgo/converter.(*autoExitInjector).Visit(0xc420120160, 0x7e6d40, 0xc4200a4600, 0x7e5f80, 0xc420120160)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:229 +0x114
go/ast.Walk(0x7e5f80, 0xc420120160, 0x7e6d40, 0xc4200a4600)
	/usr/lib/go-1.9/src/go/ast/walk.go:52 +0x68
go/ast.walkDeclList(0x7e5f80, 0xc420120160, 0xc420331280, 0x3, 0x4)
	/usr/lib/go-1.9/src/go/ast/walk.go:38 +0x83
go/ast.Walk(0x7e5f80, 0xc420120160, 0x7e6cc0, 0xc4203d0080)
	/usr/lib/go-1.9/src/go/ast/walk.go:353 +0x2672
github.com/yunabe/lgo/converter.injectAutoExit(0x7e6cc0, 0xc4203d0080, 0xc420124610)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:220 +0x81
github.com/yunabe/lgo/converter.injectAutoExitToFile(0xc4203d0080, 0xc420331800)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/autoexit.go:247 +0x7e
github.com/yunabe/lgo/converter.finalCheckAndRename(0xc4203d0080, 0xc420330a80, 0xc420afdbf0, 0xc4200a4600, 0xc4203d0080, 0xc420330c40, 0x0, 0x0, 0xc42010d450)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/converter.go:1033 +0x17ad
github.com/yunabe/lgo/converter.Convert(0xc420472000, 0x75, 0xc420afdbf0, 0x0)
	/home/ubuntu/go/src/github.com/yunabe/lgo/converter/converter.go:762 +0x8a3
github.com/yunabe/lgo/cmd/runner.(*LgoRunner).Run(0xc420330640, 0x7f3b6a558dc0, 0xc420330900, 0x7e8400, 0xc4204da6a0, 0xc420472000, 0x75, 0x77d9e0, 0x778501)
	/home/ubuntu/go/src/github.com/yunabe/lgo/cmd/runner/runner.go:147 +0x55e
main.(*handlers).HandleExecuteRequest.func3(0xc420afdd30, 0xc420010810, 0x7f3b6a558dc0, 0xc420330900, 0x7e8400, 0xc4204da6a0, 0xc4204da000)
	/home/ubuntu/go/src/github.com/yunabe/lgo/cmd/lgo-internal/kernel.go:165 +0x9b
main.(*handlers).HandleExecuteRequest(0xc420010810, 0x7f3b6a558dc0, 0xc420330900, 0xc4204da000, 0xc4204da660, 0xc4204da6a0, 0xc420484000)
	/home/ubuntu/go/src/github.com/yunabe/lgo/cmd/lgo-internal/kernel.go:168 +0x39f
github.com/yunabe/lgo/jupyter/gojupyterscaffold.(*executeQueue).loop.func1(0x7f3b6a558dc0, 0xc420330880, 0x0, 0x0)
	/home/ubuntu/go/src/github.com/yunabe/lgo/jupyter/gojupyterscaffold/execute.go:101 +0x263
github.com/yunabe/lgo/jupyter/gojupyterscaffold.(*iopubSocket).WithOngoingContext(0xc420330740, 0xc420360ef8, 0xc420490000, 0x0, 0x0)
	/home/ubuntu/go/src/github.com/yunabe/lgo/jupyter/gojupyterscaffold/shelsocket.go:85 +0xf0
github.com/yunabe/lgo/jupyter/gojupyterscaffold.(*executeQueue).loop(0xc420330780)
	/home/ubuntu/go/src/github.com/yunabe/lgo/jupyter/gojupyterscaffold/execute.go:94 +0x223
github.com/yunabe/lgo/jupyter/gojupyterscaffold.(*Server).Loop.func2(0xc4203884e0, 0xc42033c2a0)
	/home/ubuntu/go/src/github.com/yunabe/lgo/jupyter/gojupyterscaffold/gojupyterscaffold.go:190 +0x31
created by github.com/yunabe/lgo/jupyter/gojupyterscaffold.(*Server).Loop
	/home/ubuntu/go/src/github.com/yunabe/lgo/jupyter/gojupyterscaffold/gojupyterscaffold.go:189 +0xed

NOTES:

This error won't appear in case of running a code with switch true statement (not omitting condition).

import (
    "fmt"
)

n := 4
switch true {
case n > 0 && n < 3:
    fmt.Println("0 < n < 3")
case n > 3 && n < 6:
    fmt.Println("3 < n < 6")
}

Result:

3 < n < 6

publish "busy" and "idle" status to iopub when execute_reply is handled

It seems like it is important to follow this rule to use the kernel from JupyterLab

cf.
http://jupyter-client.readthedocs.io/en/latest/messaging.html#request-reply

The kernel receives that request and immediately publishes a status: busy message on IOPub. The kernel then processes the request and sends the appropriate _reply message, such as execute_reply. After processing the request and publishing associated IOPub messages, if any, the kernel publishes a status: idle message.

Jupyter Magic Commands

Are Jupyter Built-in Magic commands supported? I don't seem to be able to use them. Specifically %%time and %%save would be nice to have.

P.S. I'm using the docker image.

Code completion for import path

lgo does not complete import paths now.

We want to complete import paths for these patterns:

import [cur]

import (
    [cur]

import "a/b[cur]

import "[cur]

sql: unknown driver "postgres" (forgotten import?)

When I try to use postgres driver Got errors below.

2018/03/02 02:42:04 sql: unknown driver "postgres" (forgotten import?)
panic: runtime error: invalid memory address or nil pointer dereference

goroutine 28 [running]:
runtime/debug.Stack(0xc400000008, 0x7fc528288490, 0xc42032f370)
	/usr/local/go/src/runtime/debug/stack.go:24 +0xa9
github.com/yunabe/lgo/core.(*resultCounter).recordResult(0xc42032f358, 0x7fc52819a1a0, 0x7fc5285aa460)
	/go/src/github.com/yunabe/lgo/core/core.go:91 +0xce
github.com/yunabe/lgo/core.(*resultCounter).recordResultInDefer(0xc42032f358)
	/go/src/github.com/yunabe/lgo/core/core.go:96 +0x3b
panic(0x7fc52819a1a0, 0x7fc5285aa460)
	/usr/local/go/src/runtime/panic.go:491 +0x294
database/sql.(*DB).Close(0x0, 0x22, 0x0)
	/usr/local/go/src/database/sql/sql.go:657 +0x3c
panic(0x7fc52819a1a0, 0x7fc5285aa460)
	/usr/local/go/src/runtime/panic.go:491 +0x294
database/sql.(*DB).conn(0x0, 0x7ed2c0, 0xc420332048, 0x1, 0xc420182600, 0xc42037d6d0, 0xc42038e0c0)
	/usr/local/go/src/database/sql/sql.go:930 +0x3c
database/sql.(*DB).PingContext(0x0, 0x7ed2c0, 0xc420332048, 0xc4204abf08, 0x0)
	/usr/local/go/src/database/sql/sql.go:631 +0x93
database/sql.(*DB).Ping(0x0, 0x7fc528270f80, 0x0)
	/usr/local/go/src/database/sql/sql.go:649 +0x48
github.com/yunabe/lgo/sess7b2274696d65223a313531393935383436353337313035313531397d/exec2.lgo_init()
	/go/src/github.com/yunabe/lgo/sess7b2274696d65223a313531393935383436353337313035313531397d/exec2/src.go:31 +0x262
github.com/yunabe/lgo/cmd/runner.loadShared.func3()
	/go/src/github.com/yunabe/lgo/cmd/runner/runner.go:60 +0x26
github.com/yunabe/lgo/core.startExec.func1(0xc42032f320, 0xc4201d4bf0)
	/go/src/github.com/yunabe/lgo/core/core.go:247 +0x83
created by github.com/yunabe/lgo/core.startExec
	/go/src/github.com/yunabe/lgo/core/core.go:244 +0xcb
main routine failed

the code is here.

import (
	"database/sql"
	"log"
	"os"
    
    "github.com/lib/pq"
)

	pgURL := os.Getenv("PGURL")
	if pgURL == "" {
		log.Println("PGURL empty")
	}

	db, err := sql.Open("postgres", pgURL)
	if err != nil {
		log.Println(err)
	}
	defer db.Close()

	if err := db.Ping(); err != nil {
		log.Println(err)
	}
  • pg installed
  • PGURL setted
  • already lgo install process succesfully
/go/src/github.com/lib/pq$ ls
CONTRIBUTING.md  conn_test.go    issues_test.go        ssl_test.go
LICENSE.md       copy.go         notify.go             ssl_windows.go
README.md       ......

$PGURL
bash: "postgres://gopher:1111@localhost": No such file or directory
$ lgo install
2018/03/02 02:48:42 Install lgo to /lgo
....
2018/03/02 02:48:46 (16/115) Building "github.com/lib/pq"
.....
2018/03/02 02:49:01 (115/115) Building "gonum.org/v1/plot/vg/vgtex"
2018/03/02 02:49:01 Installing lgo-internal
2018/03/02 02:49:05 lgo was installed in /lgo successfully

How to use (postgres) database in Lgo?

Support multi-byte-encoded filenames in prebuilt docker image

If file path or filename has non-ascii character, got errors.

I'm using docker-toolbox on windows 10. and Lgo container python's default character set is below.

$ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdin.encoding
'ANSI_X3.4-1968'
>>> 

And urf-8 character not supported default in python2.

>>> import sys
>>> sys.stdin.encoding
'ANSI_X3.4-1968'
>>> b = '가'
>>> b
'\xb0\xa1'

So how about updating python version to 3.x ?

Slice function not working properly.

Hey, Lgo kernal Slice takes index 3 as index4.

here's code for reproduce error.

playground normal result

below abnormal result code:

import (
     "strings"
     "encoding/csv"
    "fmt"
    )

csvStr := `
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
`

df := strings.NewReader(csvStr)
r := csv.NewReader(df)
rawCSVData1, err := r.ReadAll()

// this printed same go & lgo
fmt.Println(rawCSVData1)

// Get first row.
row := rawCSVData1[0]

// expect [5.1 3.5 1.4 0.2 Iris-setosa]
// but    [5.1 3.5 1.4 Iris-setosa Iris-setosa]
fmt.Println(row)

// expect [5.1 3.5 1.4 0.2 Iris-setosa]
// but    [5.1 3.5 1.4 Iris-setosa Iris-setosa]
for i := 0; i<1;i++{
    fmt.Println(rawCSVData1[i])
}


// expect [5.1 3.5 1.4 0.2 Iris-setosa]
// but    [4.9 3.0 1.4 Iris-setosa Iris-setosa]
for ind, row := range rawCSVData1 {
    if ind == 1 {
        
        // expect [5.1 3.5 1.4 0.2 Iris-setosa]
        // but    [4.9 3.0 1.4 Iris-setosa Iris-setosa]
        fmt.Println(row)
        
        // expect [4.9 3.0 1.4 0.2]
        // but    [4.9 3.0 1.4 Iris-setosa]
        fmt.Println(row[0:4])
        
        // expect Iris-setosa
        // yes  Iris-setosa
        
        fmt.Println(row[4])

    }
}

Mac Support

Hi.

Any plans to support other OSes and timeframe?

`contrib` bin missing can't install nbextensions properly

I can't install nbextentions below command.

jupyter contrib nbextension install --user

so can't access nbextends with nbextenstion configurator pannel like below

image

nbextensions alerady Installed.

$ pip install jupyter_contrib_nbextensions
......
Installing collected packages: enum34, six, decorator, ipython-genutils, traitlets, jupyter-core, webencodings, html5lib, bleach, pygments, functools32, jsonschema, nbformat, mistune, testpath, MarkupSafe, jinja2, configparser, entrypoints, pandocfilters, nbconvert, scandir, pathlib2, pickleshare, simplegeneric, backports.shutil-get-terminal-s
......

install_kernel uses python2

Hello,
I spent 1 hour to find that problem :) Using Fedora 27, "python" is python 2.7. But I used "pip3" to install jupyterlab

I found that you are using a script to install lgo kernel where the first bang line is using "python", I had to change that to "python3". Maybe we must find a way to detect the right version ?

BTW: I'm creating a plot lib that already works well with lgo, I will ask you some questions for that
Other BTW: I guess I will write an article on medium.com to explain my plot lib that can only work with you almightly kernel. Really, you beat gopherlab :)

Docker build fails with a pip error

I tried building my own docker image based on the Dockerfiles in the repo, but both the one in image and the one in image_py3 fail with the below error:

Step 3/18 : RUN pip install --upgrade pip && pip install -U jupyter jupyterlab && jupyter serverextension enable --py jupyterlab --sys-prefix
 ---> Running in 88f135bba7be
Collecting pip
  Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-10.0.1
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
The command '/bin/sh -c pip install --upgrade pip && pip install -U jupyter jupyterlab && jupyter serverextension enable --py jupyterlab --sys-prefix' returned a non-zero code: 1

My docker version

λ docker version
Client:
 Version:       18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:06:28 2018
 OS/Arch:       windows/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:      18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:        Wed Mar 21 23:14:32 2018
  OS/Arch:      linux/amd64
  Experimental: false

Any thoughts?

Instruction to install lgo on my github repository?

Hi,
Is it possible to explain how we can install lgo kernel inside our own Github repository like the way you did for lgo examples?

I found the Go example notebooks I uploaded to my Github won't be executed via binder. There is no lgo kernel shown up. Any suggestion? Thanks.

Use _ctx outside the notebook

Hi again,
Very impressed by your work, I'm now able to draw plot the way I want. Here is an example:
https://nbviewer.jupyter.org/gist/metal3d/1e686fe26af2702bf3e319187cb351fd

EDIT : forget => I didn't see that gonum had plotting function, but the question is still open:

I now want to avoid the first Cell where I create helpers to draw plots. So, is there a way to make it possible to use _ctx and compile my package to let user only call "goplot.J(...)" (for example) that will make what the first cell does ?

What I do, now that I'm using gonum, is to paste that function:

func plt(p *plot.Plot, dim ...vg.Length) {
    
    w := vg.Length(550)
    h := vg.Length(300)
    
    if len(dim) > 0 {
        w = dim[0]
    }
    
    if len(dim)>1{
        h = dim[1]
    }
    
    writer, err := p.WriterTo(w, h, "png")
    if err != nil {
        panic(err)
    }
    b := []byte{}
    buff := bytes.NewBuffer(b)
    _, err  = writer.WriteTo(buff)
    if err != nil {
        panic(err)
    }
    _ctx.Display.PNG(buff.Bytes(), nil)
}

But, what I really want to do, that is to have a package (eg. plt) that export function: "plt.Plot(* plot.Plot)" without to have to copy/paste my function each time.

Any idea ?

Thanks a lot, one more time, for LGo

Open boltDB makes kernel dead.

Trying to opening database make kernel dead.

I install bold DB container & log install got 2018/02/28 06:36:17 lgo was installed in /lgo successfully message.

and I run below code. got kernel dead.

import (
	"log"

	"github.com/boltdb/bolt"
)

func main() {
	// Open the my.db data file in your current directory.
	// It will be created if it doesn't exist.
	db, err := bolt.Open("my.db", 0600, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

}

main()

from

my.db file created.

I think it's not involved with file. golang-scribble makes dir and json file well.

Basic Notebooks Fail When Running with Docker on MacOS

I'm running the dockerized version of lgo on MacOS 10.13.3. I've successfully launched the docker container and logged into the jupyter notebook server. However, when I try to run a cell in the basics.ipynb notebook, I get the following error:

# /tmp/go-build175073157/libgithub.com-yunabe-lgo-sess7b2274696d65223a313532323737353439343231353335333930307d-exec1.so
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
collect2: fatal error: ld terminated with signal 4 [Illegal instruction]
compilation terminated.

Failed to build a shared library of github.com/yunabe/lgo/sess7b2274696d65223a313532323737353439343231353335333930307d/exec1: exit status 2

type and its methods must be in the same jupyter cell

Declaring a type B in one cell, and its methods in another cell, produces the error:

1:7: invalid receiver github.com/yunabe/lgo/sess7b2274696d65223a313532333232333935393234383932303932307d/exec2.B (type not defined in this package)

I'd say it's a limitation rather than a bug - inconvenient, nevertheless

yunabe-lgo-method-in-different-cell

Renaming to access unexported names is broken inside a function

When f and st are predefined, the following code

func myFunc() {
	a := f(3)
	s := st{
		value: a,
	}
	var i interface{} = &s
	i.(*st).getValue()
}

is converted to

func Def_myFunc() {
	a := Ref_pkg0.f(3)
	s := Ref_pkg0.st{Ref_value: a}
	var i interface{} = &s
	i.(*Ref_pkg0.st).Ref_getValue()
}

Need documenting difference jupyter notebook bin names.

I tried install nbextensions got erros.

and figured out bin file name is different from nomals.

jupyter-contrib tells jupyter nbextensions_configurator enable --user, but there is no contrib things.

so many tries. so get the bin path like below.

$ pip uninstall jupyter_nbextensions_configurator
Uninstalling jupyter-nbextensions-configurator-0.4.0:
  /home/gopher/.local/bin/jupyter-nbextensions_configurator
  /home/gopher/.local/lib/python2.7/site-packages/jupyter_nbextensions_configurator-0.4.0.dist-info/DESCRIPTION.rst

lgo has another bin names.

~/.local/bin$ ls
easy_install                 jupyter-kernelspec
easy_install-2.7             jupyter-migrate
iptest                       jupyter-nbconvert
iptest2                      jupyter-nbextension
ipython                      jupyter-nbextensions_configurator
ipython2                     jupyter-notebook
jsonschema                   jupyter-run
jupyter                      jupyter-serverextension
jupyter-bundlerextension     jupyter-troubleshoot

I don't know what's origin, but we need documentation about it.

for avoiding so many time wasting.

Can't install external packages

I can't install external packages that work fine with regular Go.

~ go version
go version go1.9.5 linux/amd64
~ jupyter --version
4.4.0
~ export LGOPATH=$HOME/lgo
~ mkdir $LGOPATH
~ go get github.com/yunabe/lgo/cmd/lgo && go get -d github.com/yunabe/lgo/cmd/lgo-internal
~ lgo install
2018/04/24 12:10:14 Install lgo to /home/peter/lgo
2018/04/24 12:10:14 Building libstd.so
2018/04/24 12:10:21 Building lgo core package
2018/04/24 12:10:22 Building third-party packages in $GOPATH
2018/04/24 12:10:22 Installing lgo-internal
2018/04/24 12:10:24 lgo was installed in /home/peter/lgo successfully
~ go get github.com/pebbe/util
~ lgo installpkg github.com/pebbe/util
# /tmp/go-build211418391/libgithub.com-pebbe-util.so
github.com/pebbe/util.Open: missing section for relocation target github.com/pebbe/util.(*ReadCloser).Close·f
github.com/pebbe/util.Open: missing section for relocation target github.com/pebbe/util.(*ReadCloser).Close·f
github.com/pebbe/util.Open: missing section for relocation target github.com/pebbe/util.(*ReadCloser).Close·f
github.com/pebbe/util.Open: reloc 26 to non-elf symbol github.com/pebbe/util.(*ReadCloser).Close·f (outer=github.com/pebbe/util.(*ReadCloser).Close·f) 0
github.com/pebbe/util.Open: reloc 26 to non-elf symbol github.com/pebbe/util.(*ReadCloser).Close·f (outer=github.com/pebbe/util.(*ReadCloser).Close·f) 0
github.com/pebbe/util.Open: reloc 26 to non-elf symbol github.com/pebbe/util.(*ReadCloser).Close·f (outer=github.com/pebbe/util.(*ReadCloser).Close·f) 0
github.com/pebbe/util.Open: undefined: "github.com/pebbe/util.(*ReadCloser).Close·f"
github.com/pebbe/util.Open: undefined: "github.com/pebbe/util.(*ReadCloser).Close·f"
github.com/pebbe/util.Open: undefined: "github.com/pebbe/util.(*ReadCloser).Close·f"
(1/1) failed to install "github.com/pebbe/util": exit status 2
2018/04/24 12:12:19 failed to install .so files
~ python $(go env GOPATH)/src/github.com/yunabe/lgo/bin/install_kernel
Installing Jupyter kernel spec
~ jupyter console --kernel lgo
Jupyter console 5.2.0

lgo


In [1]: import "github.com/pebbe/util"
found packages not installed in LGOPATH: [github.com/pebbe/util]
# /tmp/go-build777551001/libgithub.com-pebbe-util.so
github.com/pebbe/util.Open: missing section for relocation target github.com/pebbe/util.(*ReadCloser).Close·f
github.com/pebbe/util.Open: missing section for relocation target github.com/pebbe/util.(*ReadCloser).Close·f
github.com/pebbe/util.Open: missing section for relocation target github.com/pebbe/util.(*ReadCloser).Close·f
github.com/pebbe/util.Open: reloc 26 to non-elf symbol github.com/pebbe/util.(*ReadCloser).Close·f (outer=github.com/pebbe/util.(*ReadCloser).Close·f) 0
github.com/pebbe/util.Open: reloc 26 to non-elf symbol github.com/pebbe/util.(*ReadCloser).Close·f (outer=github.com/pebbe/util.(*ReadCloser).Close·f) 0
github.com/pebbe/util.Open: reloc 26 to non-elf symbol github.com/pebbe/util.(*ReadCloser).Close·f (outer=github.com/pebbe/util.(*ReadCloser).Close·f) 0
github.com/pebbe/util.Open: undefined: "github.com/pebbe/util.(*ReadCloser).Close·f"
github.com/pebbe/util.Open: undefined: "github.com/pebbe/util.(*ReadCloser).Close·f"
github.com/pebbe/util.Open: undefined: "github.com/pebbe/util.(*ReadCloser).Close·f"
(1/1) failed to install "github.com/pebbe/util": exit status 2
failed to install .so files

~ ls -l $LGOPATH/pkg/github.com/pebbe
totaal 76
-rw-r--r-- 1 peter peter 74992 apr 24 12:11 util.a
~ ls -l $GOPATH/pkg/linux_amd64/github.com/pebbe
totaal 72
-rw-r--r-- 1 peter peter 73020 apr 24 12:11 util.a

import with _ is ignored completely

In Go, import with _ is used to load and initialize library (e.g. _ "image/png").
But it's completely ignored in lgo because lgo removes all unused imports now.

Issue facing with install Centos7

How to get around this issue ? Machine has zmq3 already why would it try to build zmq4 ...

19:31:31 Installing lgo-internal
# github.com/pebbe/zmq4
/tmp/go-build824050319/github.com/pebbe/zmq4/_obj/zmq4.cgo2.o: In function `_cgo_5202562de717_C2func_zmq_ctx_term':
../src/github.com/pebbe/zmq4/cgo-gcc-prolog:179: undefined reference to `zmq_ctx_term'
/tmp/go-build824050319/github.com/pebbe/zmq4/_obj/zmq4.cgo2.o: In function `_cgo_5202562de717_C2func_zmq_curve_keypair':
../src/github.com/pebbe/zmq4/cgo-gcc-prolog:202: undefined reference to `zmq_curve_keypair'
/tmp/go-build824050319/github.com/pebbe/zmq4/_obj/zmq4.cgo2.o: In function `_cgo_5202562de717_Cfunc_zmq_ctx_term':
../src/github.com/pebbe/zmq4/cgo-gcc-prolog:619: undefined reference to `zmq_ctx_term'
/tmp/go-build824050319/github.com/pebbe/zmq4/_obj/zmq4.cgo2.o: In function `_cgo_5202562de717_Cfunc_zmq_curve_keypair':
../src/github.com/pebbe/zmq4/cgo-gcc-prolog:638: undefined reference to `zmq_curve_keypair'
/tmp/go-build824050319/github.com/pebbe/zmq4/_obj/zmq4.cgo2.o: In function `_cgo_5202562de717_Cfunc_zmq_z85_decode':
../src/github.com/pebbe/zmq4/cgo-gcc-prolog:921: undefined reference to `zmq_z85_decode'
/tmp/go-build824050319/github.com/pebbe/zmq4/_obj/zmq4.cgo2.o: In function `_cgo_5202562de717_Cfunc_zmq_z85_encode':
../src/github.com/pebbe/zmq4/cgo-gcc-prolog:940: undefined reference to `zmq_z85_encode'
collect2: error: ld returned 1 exit status
2018/03/10 19:31:36 Failed to build lgo-internal: exit status 2

dataframe package does not work

Hi,

I noticed that there is dataframe package installed. But it does not work properly when calling import. Thanks.

import "github.com/kniren/gota/dataframe"

1:8: could not import github.com/kniren/gota/dataframe (open /lgo/pkg/github.com/kniren/gota/dataframe.a: no such file or directory)

Error using lgo with juypterhub

I'm trying to install lgo so I can use it in notebooks on jupyterhub. I'm using the base jupyterhub image and added the commands to install lgo.

The Dockerfile I am using is here. After starting the container I

  1. add a user (using the adduser cmd from within docker exec)
  2. login
  3. create a notebook using the lgo kernal
  4. get an error

The error I am seeing is

[I 2018-04-23 03:09:17.306 SingleUserNotebookApp restarter:110] KernelRestarter: restarting kernel (1/5), new random ports
2018/04/23 03:09:17 LGOPATH is empty
[I 2018-04-23 03:09:20.320 SingleUserNotebookApp restarter:110] KernelRestarter: restarting kernel (2/5), new random ports
2018/04/23 03:09:20 LGOPATH is empty

If I echo $LGOPATH inside the running container, I see /lgo so not sure why that error is happening.

Any help with a working Dockerfile for running jupyterhub with lgo installed?

interface is not working

If you invoke a method through an interface in lgo, it crashes with runtime error: invalid memory address or nil pointer dereference.

Cannot set notebook password

When I try to set password instead of token on terminal, I got some error. (also on loginpage,)

here's errors and against.

  1. out side of container. “Can not control echo on the terminal” = docker exec -ti bash
  2. no congirugation file => type 'jupyter notebook --generate-config`
  3. ValueError: No JSON object could be decoded => !!!!!!stuck!!!

I want to manually edit conf file using text editor... but I can't find & install them.

It's a bug, I think.

Add support for startup scripts

Jupyter (IPython) supports startup scripts. When the kernel starts, it loads all the files present in the startup directory (usually ~/.ipython/profile_default/startup or ~/.jupyter/startup) in lexicographical order.

Add support for loading any *.go files found in the directory during startup.

Jupyter kernel keeps dying and restarting

Hello, I'm trying to make Igo work. I've installed following the guide. I tested that go is installed, I tested lgo repl and it works (when I run it like ./lgo run).
But in my Jupyter notebook server, the kernel keeps dying and simply doesn't work.
Can you help me out? Thanks!

lgo kernel exits if GOPATH is unset

on go1.10, Linux amd64:

after installing lgo, everything works as expected if I type export GOPATH=~/go before jupyter notebook

instead, lgo kernel exits if GOPATH is unset (see below).

Nowadays, GOPATH is almost never needed or set. In my opinion, requiring a correct GOPATH is a pitfall where beginners may (and will) trip - that's also why Go team made it optional.

$ unset GOPATH
$ jupyter notebook
[I 23:35:01.481 NotebookApp] The port 8888 is already in use, trying another port.
[I 23:35:01.486 NotebookApp] Serving notebooks from local directory: /home/max
[I 23:35:01.486 NotebookApp] 0 active kernels
[I 23:35:01.486 NotebookApp] The Jupyter Notebook is running at:
[I 23:35:01.486 NotebookApp] http://localhost:8889/?token=00cec63216523dd4fdce2bf83b56f542c2c089a5d2cc46b3
[I 23:35:01.486 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 23:35:01.486 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8889/?token=00cec63216523dd4fdce2bf83b56f542c2c089a5d2cc46b3
[I 23:35:01.599 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 23:35:07.494 NotebookApp] Creating new notebook in 
2018/04/08 23:35:08 GOPATH is not set
[I 23:35:08.614 NotebookApp] Kernel started: abbe79b6-dff7-481d-965d-e0b574106a22
[I 23:35:11.615 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
2018/04/08 23:35:11 GOPATH is not set
[I 23:35:14.622 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
2018/04/08 23:35:14 GOPATH is not set
[I 23:35:17.632 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
2018/04/08 23:35:17 GOPATH is not set
[W 23:35:18.671 NotebookApp] Timeout waiting for kernel_info reply from abbe79b6-dff7-481d-965d-e0b574106a22
[I 23:35:20.642 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
WARNING:root:kernel abbe79b6-dff7-481d-965d-e0b574106a22 restarted
2018/04/08 23:35:20 GOPATH is not set
[W 23:35:23.650 NotebookApp] KernelRestarter: restart failed
[W 23:35:23.651 NotebookApp] Kernel abbe79b6-dff7-481d-965d-e0b574106a22 died, removing from map.
ERROR:root:kernel abbe79b6-dff7-481d-965d-e0b574106a22 restarted failed!
[W 23:35:23.688 NotebookApp] 410 DELETE /api/sessions/b0b1b0b0-2018-4ef8-975a-ccd83d315e9d (::1): Kernel deleted before session
[W 23:35:23.689 NotebookApp] Kernel deleted before session
[W 23:35:23.689 NotebookApp] 410 DELETE /api/sessions/b0b1b0b0-2018-4ef8-975a-ccd83d315e9d (::1) 1.26ms referer=http://localhost:8889/notebooks/Untitled1.ipynb?kernel_name=lgo

yunabe-lgo-gopath-unset-error

Invalid Credentials using Docker on MacOS

I'm using the dockerized version of lgo to try to run a notebook on MacOS 10.13.3. After downloading the latest lgo, I run

docker-compose up -d

From the lgo/docker/jupyter directory.
I list the notebooks in the container and see:

Currently running servers:
http://0.0.0.0:8888/?token=4a945b4b262fc0c58fef638e019f2df447d7618bfbb5b021 :: /examples

But when I paste that link into chrome 65.0.3325.181, I see the jupyter login page. If I try to enter just the token into that page I see "Invalid credentials." Am I missing a step?

invalid credentials

Cannot run with docker-compose on MacOS

bash-3.2$ git clone https://github.com/yunabe/lgo.git
Cloning into 'lgo'...
remote: Counting objects: 1186, done.
remote: Compressing objects: 100% (180/180), done.
remote: Total 1186 (delta 73), reused 150 (delta 49), pack-reused 943
Receiving objects: 100% (1186/1186), 915.45 KiB | 1.06 MiB/s, done.
Resolving deltas: 100% (570/570), done.
bash-3.2$ cd lgo/docker/jupyter
bash-3.2$ docker-compose up -d
Creating network "jupyter_default" with the default driver
Building jupyter
Step 1/3 : FROM yunabe/lgo:latest
ERROR: Service 'jupyter' failed to build: Get https://registry-1.docker.io/v2/yunabe/lgo/manifests/latest: unauthorized: incorrect username or password

Lgo fails to complete TestFunc with input testF

When the input's length is greater than the first capital letter's position of the suggestion. For example, if the input is testF and expected suggestion is TestFunc, it failed to suggest anything.

GC crashes with a fatal error

The following code crashes with a fatal error: found bad pointer in Go heap (incorrect use of unsafe or cgo?) message

import (
    "fmt"
    "log"
    "runtime"
)

type MyData struct {
    b []byte
}

func (m *MyData) Size() int {
    return len(m.b)
}

func NewMyData() *MyData {
    return &MyData{
        b: make([]byte, 10 * (1 << 20)),
    }
}

var l []*MyData
for i := 0; i < 100; i++ {
    d := NewMyData()
    l = append(l, d)
}
l = nil
runtime.GC()

Show longer documentation

Any way to show longer Docstring like Python kernel's?

For example to show docs for GoStringer
image
looks like doc is truncated

Usually in Python I'll use
?fmt.GoStringer()
but apparently it doesn't work as well

Port 8888

This port is most likely used by proxy servers. I'd recommend to use another port. Anyway, this repo is superb! Thank you.

Stop printing return values of fmt.Print functions

In the current version, lgo always prints the result of the last expression.
Because of this spec, lgo prints (n, error) pair if the last statement of a code block is fmt.Println(...).
Obviously, this is not an ideal behavior. We should stop printing the last expression under some conditions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.