之前在学习python时,用了jupyter, 有时候想写一些测试代码时, 也可以直接打开网页编写, 非常方便。
今天在github上找到一个项目, 就可以实现在jupyter上运行go代码, 如下图

项目地址:https://github.com/gopherdata/gophernotes
这里github的官方教程上, 关于linux的教程, 有一点问题, 由于go的新版本现在默认开启了mod模式, 所以照着教程来, 会报错, 这里整理一下
注意:这里默认你已经装了jupyter和go
go install github.com/gopherdata/gophernotes@latest mkdir -p ~/.local/share/jupyter/kernels/gophernotes cd ~/.local/share/jupyter/kernels/gophernotes cp "$(go env GOPATH)"/pkg/mod/github.com/gopherdata/gophernotes@v0.7.5/kernel/* "." chmod +w ./kernel.json sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json
然后重启jupyter, 在新建文件的地方,就可以看到go的内核了,

发表回复