go-notebook documentation
You are reading the documentation of an outdated version, whose text may no longer be accurate. Go to the latest version.
A notebook is a Markdown file whose ```go blocks are cells. The
go-notebook kernel:
- compiles it into a real Go program, so cells run at native speed;
- orders the cells by what they use, worked out from the code itself as marimo does for Python, not by the order you ran them in;
- runs only what changed. A cell whose code and inputs did not change keeps its result, and its values are handed over instead of being computed again. That holds across rebuilds and across runs: results and values are kept on disk.
Install
go install github.com/go-notebook/notebook/cmd/notebook@latestThe module needs Go 1.27.2 or later.
A first notebook
# Spectrum
```go
import "math"
n := 1_000_000
```
The sum below runs once; editing the last cell does not run it again.
```go
sum := 0.0
for i := 1; i <= n; i++ {
sum += 1 / float64(i*i)
}
```
```go
math.Sqrt(6 * sum)
```Run it, change the last cell to math.Pi - math.Sqrt(6*sum), and run it again:
$ notebook run spectrum.md
── cell 0 (line 4, ran in 12µs)
── cell 1 (line 12, ran in 2.663ms)
── cell 2 (line 19, ran in 36µs)
3.1415916986605086
$ notebook run spectrum.md
── cell 0 (line 4, kept)
── cell 1 (line 12, kept)
── cell 2 (line 19, ran in 42µs)
9.54929284535666e-07
The second run is a new process: sum comes back from the kernel’s store, it
is not summed again. (A real transcript, from notebook built at main
fd7f8c1 on an Apple M4 Max; timings vary by machine.)
Where to go next
| Page | What it covers |
|---|---|
| Notebooks | what a notebook file is, and why it is Markdown |
| Cells | the rules a cell follows, and the errors that enforce them |
| The notebook command | run, html, watch and serve, and their flags |
| The kernel | how the kernel decides what to run, and what it keeps |
| Design | what exists already, what each gets wrong, and the decisions behind go-notebook |
go-notebook is part of an ecosystem with
go-ndarray (NumPy-style arrays) and
go-fft (numpy.fft). The source is at
github.com/go-notebook/notebook,
under the BSD-3-Clause licence.
Created on by tannevaled
Modified on by tannevaled