persist

package module
v0.0.0-...-15bf84b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 4 Imported by: 0

README

gonb-persist - Utility package for persiting variables in gonb

What does this do?

This is a very small pacakge that makes it easy to use and modify variables in a gonb (github.com/janpfeifer/gonb) notebook.

Why not use github.com/janpfeifer/gonb/cache?

The cache package is much better written than this. It has better error handling and is more customisable. However, I prefer this package becasue it is simpler to modify variables in multiple cells.

How to use

First install gonb. Then have a look at example.ipynb.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean()

Clean removes all cache from previous runs and ensures the directory exists

func Init

func Init() bool

Init initialises variable persistence with the default directory (./cache/)

func InitWithDir

func InitWithDir(dir string) bool

InitWithDir initialises variable persistence with a given directory

Types

type PersisentVar

type PersisentVar[T any] struct {
	V    T      // The actual variable
	Name string // The name of the variable
}

func Load

func Load[T any](name string) *PersisentVar[T]

Load creates a persistent variable which is stored under the name. The name should be unique

func (*PersisentVar[T]) Save

func (v *PersisentVar[T]) Save()

Save saves the state of the variable so that other cells can use it

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL