{"id":13563758,"url":"https://github.com/janpfeifer/gonb","last_synced_at":"2025-05-14T15:06:30.175Z","repository":{"id":65788701,"uuid":"599714179","full_name":"janpfeifer/gonb","owner":"janpfeifer","description":"GoNB, a Go Notebook Kernel for Jupyter","archived":false,"fork":false,"pushed_at":"2025-02-02T09:36:08.000Z","size":127337,"stargazers_count":824,"open_issues_count":10,"forks_count":42,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-12T20:43:42.022Z","etag":null,"topics":["data-science","go","golang","gonb","jupyter","jupyter-notebook","jupyter-notebook-kernel"],"latest_commit_sha":null,"homepage":"https://github.com/janpfeifer/gonb","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janpfeifer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-09T18:17:42.000Z","updated_at":"2025-04-11T14:40:49.000Z","dependencies_parsed_at":"2023-09-24T15:55:23.155Z","dependency_job_id":"58e6c2f1-17b4-4e59-a2a7-f871da6f24dd","html_url":"https://github.com/janpfeifer/gonb","commit_stats":{"total_commits":439,"total_committers":7,"mean_commits":"62.714285714285715","dds":"0.22323462414578588","last_synced_commit":"0745a3825ad8517a7a696403c013d1753d96ae51"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpfeifer%2Fgonb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpfeifer%2Fgonb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpfeifer%2Fgonb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpfeifer%2Fgonb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janpfeifer","download_url":"https://codeload.github.com/janpfeifer/gonb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254169062,"owners_count":22026208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","go","golang","gonb","jupyter","jupyter-notebook","jupyter-notebook-kernel"],"created_at":"2024-08-01T13:01:23.006Z","updated_at":"2025-05-14T15:06:30.123Z","avatar_url":"https://github.com/janpfeifer.png","language":"Go","funding_links":[],"categories":["Software Packages","Go","Go Tools","软件包"],"sub_categories":["Other Software","其他软件"],"readme":"# GoNB, A Modern Go Kernel for Jupyter 📓Notebooks📓\n\n[![GoDev](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white)](https://pkg.go.dev/github.com/janpfeifer/gonb?tab=doc)\n[![GitHub](https://img.shields.io/github/license/janpfeifer/gonb)](https://github.com/Kwynto/gosession/blob/master/LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/janpfeifer/gonb)](https://goreportcard.com/report/github.com/janpfeifer/gonb)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/janpfeifer/gonb/HEAD?labpath=examples%2Ftutorial.ipynb)\n[![TestStatus](https://github.com/janpfeifer/gonb/actions/workflows/go.yaml/badge.svg)](https://github.com/janpfeifer/gonb/actions/workflows/go.yaml)\n![Coverage](https://img.shields.io/badge/Coverage-64.7%25-yellow)\n\n\n\n## For a quick start, see the [**tutorial** 🧭](examples/tutorial.ipynb)\n\n## ✨ Highlights:\n\n\u003cimg align=\"right\" width=\"480px\" src=\"https://repository-images.githubusercontent.com/599714179/38d0328a-abdb-4f69-9617-6ef136390708\"\u003e\n\n* Auto-complete and contextual help while coding.\n* Rich content display: HTML, markdown (with latex), images, javascript, svg, videos, etc.\n  * Widgets (sliders, buttons) support: interact using HTML elements. Create your own widgets!\n  * [Plotly integration](https://plotly.com/javascript/) using [go-plotly](https://github.com/MetalBlueberry/go-plotly) (see example in [tutorial](examples/tutorial.ipynb))\n  * [Apache ECharts](https://echarts.apache.org/en/index.html) integration using [gonb-echarts](https://github.com/janpfeifer/gonb-echarts) and [go-echarts](https://github.com/go-echarts/go-echarts): see [examples](https://janpfeifer.github.io/gonb-echarts/)\n* Uses standard Go compiler: 100% compatibility with projects, even those using CGO.\n  It also supports arbitrary Go compilation flags to be used when executing the cells.\n* Faster execution than interpreted Go, used in other similar kernels -- at the cost of imperceptible increased \n  start up, since each cell is compiled.\n* Supported by [Jupytext](https://github.com/mwouts/jupytext): it allows one to write the notebook as a normal.\n  Go file, and use [Jupytext](https://github.com/mwouts/jupytext) to convert to a notebook (with markdown support, etc).\n  See [example](https://github.com/mwouts/jupytext/issues/1244#issuecomment-2202097837).\n* Run cell's `Test*` and `Benchmark*` functions with `go test`, simply adding `%test` to cell.\n* Support for `go.mod` and `go.work`, to allow local development. Including importing specific versions of libraries.\n* Debug using [gdlv](https://github.com/aarzilli/gdlv), a GUI for the [delve](https://github.com/go-delve/delve) debugger (see %help).\n* Shell command executions with `!` -- handy at times, for instance to install packages.\n* Reported to work with Github Codespace, [VSCode](docs/VSCode.md), Binder, Google's Colab, etc.\n* Very well documented and supported.\n* Great for data-science, testing, writing reports, live demos, etc.\n* Includes a [pre-built docker](https://hub.docker.com/r/janpfeifer/gonb_jupyterlab), that includes JupyterLab and GoNB, that can be used to easily try it out. Alternatively, there is a [Google's Colab](https://colab.research.google.com/drive/1vUd3SSoOm2K6UQLnkJQursZZx4CaIT_1?usp=sharing), that bootstraps **GoNB** and can be used online.\n* Online help and much more, see `%help`.\n* Compile and execute the Go code as WASM: allows one to do interactive widgets in notebooks. See `%wasm` (EXPERIMENTAL).\n\n## 👁️‍🗨️ Examples:\n\n### Auto-complete and Contextual Help\n\n\u003cimg src=\"docs/GoNB-Demo.png\" alt=\"Auto-complete Demo\" width=\"50%\" height=\"50%\"/\u003e\n\n### [Flowers Diffusion Model Demo](https://github.com/gomlx/gomlx/blob/main/examples/oxfordflowers102/OxfordFlowers102_Diffusion.ipynb)\n\nhttps://github.com/janpfeifer/gonb/assets/7460115/f1187dad-4c10-4d21-a73e-9090019680ae\n\n### Sine Plot Connected to Slider\n(See full code in the [**tutorial**](examples/tutorial.ipynb))\n\n\u003cimg src=\"docs/demo-widgets.gif\" alt=\"Widgets Demo\" width=\"50%\" height=\"50%\"/\u003e\n\n### Example Screenshotting Wikipedia\n\n\u003cimg src=\"docs/demo-browser.png\" alt=\"Browser Screenshot Demo\" width=\"50%\" height=\"50%\"/\u003e\n\n## 🌱 Introduction\n\nGo is a compiled language, but with very fast compilation, that allows one to use\nit in a REPL (Read-Eval-Print-Loop) fashion, by inserting a \"Compile\" step in the middle\nof the loop -- so it's a Read-Compile-Run-Print-Loop — while still feeling very interactive. \n\n**GoNB** leverages that compilation speed to implement a full-featured (at least it's getting there)\n[Jupyter notebook](https://jupyter.org/) kernel.\nAs a side benefit it works with packages that use CGO — although it won't parse C code in the cells,\nso it can't be used as a C kernel.\n\nIt already includes many goodies: cache between cell of results, contextual help and auto-complete (with \n[`gopls`](https://github.com/golang/tools/tree/master/gopls)),\ncompilation error context (by mousing over), bash command execution, images, html, etc.\nSee the [tutorial](examples/tutorial.ipynb).\n\nIt's been heavily used by the author (in developing [GoMLX](https://github.com/gomlx/gomlx), a machine \nlearning framework for Go), but should still be seen as **experimental** — if we hear success stories\nfrom others, we can change this.\n\nReports of issues as well as fixes are always welcome.\n\nThere is also\n[a live version in Google's Colab](https://colab.research.google.com/drive/1vUd3SSoOm2K6UQLnkJQursZZx4CaIT_1?usp=sharing)\nthat one can interact with (make a copy first) — if the link doesn't work (Google Drive sharing publicly\nis odd), [download it from GitHub](examples/google_colab_demo.ipynb) and upload it to Google's Colab.\n\nFinally, because it's compiled and not interpreted, it has a slightly different \"semantic\" than the Python kernels.\nIt's highly recommended quickly browsing through the [**tutorial**](examples/tutorial.ipynb).\n\n## 📦 Installation\n\n**Only for Linux and macOS. In Windows, it works in WSL or inside a Docker**\n\n\n### 🐳 Docker\n\nGoNB offers a [pre-built docker](https://hub.docker.com/r/janpfeifer/gonb_jupyterlab), \nthat includes JupyterLab and GoNB. \nTo use it, go to a directory that you want to make available to the Jupyter notebook \n(your home directory, or a directory where to store the notebook files).\nIt will be mounted on the `host/` subdirectory in JupyterLab.\n\nTo start it:\n\n```shell\ndocker pull janpfeifer/gonb_jupyterlab:latest\ndocker run -it --rm -p 8888:8888 -v \"${PWD}\":/notebooks janpfeifer/gonb_jupyterlab:latest\n```\n\nThen copy\u0026paste the URL that it outputs in your browser.\n\n**Note**: The docker allows for customization by running an arbitrary script at start up as `root`, which allows\none to install any planned dependencies. See [docker.md](docs/docker.md) for details.\n\n### Linux and macOS Installation Using Standard Go Tools\n\nThe [official tutorial on how to install go programs here](https://go.dev/doc/tutorial/compile-install) --\nit is pretty simple, go maintains a `GOBIN` directory (that you can set) and `go install` will compile\nprograms and put it there. You should add the `GOBIN` directory to your `PATH` (the default list of directories\nto search for executables).\n\nYou need to install (if not yet there), **GoNB**, `goimports` and `gopls` (for auto-complete), and then run \n`gonb --install`. To install them in your `GOBIN` directory:\n\n```bash\ngo install github.com/janpfeifer/gonb@latest \u0026\u0026 \\\n  go install golang.org/x/tools/cmd/goimports@latest \u0026\u0026 \\\n  go install golang.org/x/tools/gopls@latest\n```\n\nAnd if `GOBIN` is in your `PATH`, run the following to install **GoNB** as a kernel in the Jupyter configuration\n(works for both JupyterLab and Jupyter Notebook).\n\n```bash\ngonb --install\n```\n\nAnd then (re-)start Jupyter (if it is already running).\n\nIn GitHub's Codespace, if Jupyter is already started, restart the docker — it will also restart Jupyter.\n\n**Note**: for `go.work` to be parsed correctly for auto-complete, you need `gopls` version greater or equal \nto v0.12.4 (or at least `v0.12.0`?).\nYou can check it with `gopls version`.\n\n### Windows\n\nThe recommendation is to use [WSL (Windows Subsystem for Linux)](https://learn.microsoft.com/en-us/windows/wsl/install)\nor WSL2, and run Jupyter and the GoNB kernel in the Linux/WSL environment. \nInstall there as if it were in a linux machine.\n\nA pure Windows installation is not supported at this time — but contributions to add support for it would be welcome :)\n\n## 🤔 FAQ\n\n* Is there are reference documentation ?\n  * There is a help (run `%help` in a cell) and a [**tutorial**](examples/tutorial.ipynb), which is kept up-to-date and\n    is comprehensive -- it includes every GoNB feature.\n  * The libraries that are used or UI, Widgets and manipulating the DOM in the notebook's browser, are all under the package `gonbui`.\n    They are described in the [**tutorial**](examples/tutorial.ipynb), but also documented in [pkg.go.dev](https://pkg.go.dev/github.com/janpfeifer/gonb/gonbui?tab=doc).\n* What is the `%%` symbol seen everywhere?\n  * It is a special commands for *GoNB* that means \"insert a `func main {...}` here\".\n* Go error handling is verbose and annoying for things interactive as a notebook. Can we do something ?\n  * Yes! Error handling for small scripts in a notebook can get in the way at times. There are various\n    solutions to this. Often folks create a series of `Must()` functions, or simply use\n    [this trivial `must` package](https://github.com/janpfeifer/must).\n\n## 📝 TODOs\n\nContributions are welcome! \n\n* Windows version: \n  * Installation.\n  * Named-pipe implementation in `kernel/pipeexec.go`.\n\n##  💖 Thanks\n\n* [Go](golang.org)\n* [Jupyter](https://jupyter.org/), what an awesome project.\n* [gophernotes](https://github.com/gopherdata/gophernotes), from which this is a highly modified fork, little from the original code exists.\n* The Go gopher logo (`internal/kernel`) used in the installation of the Jupyter kernel was designed by Renee French\n  (http://reneefrench.blogspot.com/), see Creative Commons 3.0 Attributions license in\n  [Wikimedia](https://commons.wikimedia.org/wiki/File:Go_gopher_favicon.svg).\n\n## 🤝 Contributing\n\nContributions are very welcome. The code is generally well documented -- not always, but mostly. There are a also a couple of guides worth reading if contributing in the [`docs/`](https://github.com/janpfeifer/gonb/tree/main/docs) subdirectory.\n\nThere are two parts of the project:\n\n1. The kernel itself: that builds the binary package. Most subpackages are under `internal/`.\n2. The UI library in the packages under `github.com/janpfeifer/gonb/gonbui`.\n\n##  🌟 Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=janpfeifer/gonb\u0026type=Date)](https://star-history.com/#janpfeifer/gonb\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanpfeifer%2Fgonb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanpfeifer%2Fgonb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanpfeifer%2Fgonb/lists"}