Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FST

FST provides an immutable map from byte keys to byte values, compiled from a strictly sorted stream. Lookups walk a packed buffer and do not allocate a Go map. The package uses only the Go standard library.

Installation

The package requires Go 1.26 or newer.

go get github.com/lemric/fst-go

Quick start

package main

import (
	"fmt"
	"log"

	"github.com/lemric/fst-go"
)

func main() {
	builder := fst.NewBuilder()
	if err := builder.Insert([]byte("faktury"), []byte("faktura")); err != nil {
		log.Fatal(err)
	}
	if err := builder.Insert([]byte("umowy"), []byte("umowa")); err != nil {
		log.Fatal(err)
	}
	dict, err := builder.Finish()
	if err != nil {
		log.Fatal(err)
	}
	lemma, ok := dict.Get([]byte("faktury"))
	if !ok {
		log.Fatal("missing")
	}
	fmt.Println(string(lemma))
}

Load reconstructs a map from Map.Bytes() so a compiled dictionary can be embedded or memory-mapped. Insert keys in lexicographic order.

Testing

go test ./...
go test -race ./...
go vet ./...

License

This package is released under the MIT License.

About

Immutable finite-state byte map for Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages