1
0

Lockable memory storage for Go https://pkg.go.dev/github.com/annybs/go-registry

Aneurin Barker Snook 92c96c9507 add tests 10 сар өмнө
.github 92c96c9507 add tests 10 сар өмнө
.gitignore 1488b507e7 ensure go.sum not committed 10 сар өмнө
LICENSE.md f468c349ac duplicate license to each package 11 сар өмнө
README.md 97290b6abd fix link to license 10 сар өмнө
go.mod f76498ae62 rename package 10 сар өмнө
registry.go 85c166f101 add readme for each package 11 сар өмнө
registry_test.go 6b3a2377a7 add validation error type, fix tests, add number tests 1 жил өмнө

README.md

Go Registry

This package provides a simple registry implementation which allows storing arbitrary values in a memory map.

You can also lock specific keys to prevent them being written, even if no value has yet been set. Locked keys cannot be unlocked.

Example

package main

import (
	"fmt"

	"github.com/annybs/go/registry"
)

func main() {
	r := registry.New()

	r.Set("some key", "some text")
	fmt.Println(r.Get("some key"))

	r.Lock("some key")
	if err := r.Set("some key", "different text"); err != nil {
		fmt.Println(err)
	}
}

License

See LICENSE.md