util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package util holds small shared helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCJKFunctionWord

func IsCJKFunctionWord(w string) bool

IsCJKFunctionWord reports whether w is a single-ideograph Chinese function word (a high-frequency word with little retrieval signal). Multi-character strings are never function words.

func IsStopword

func IsStopword(w string) bool

IsStopword reports whether a lowercase token is a function word (Latin or CJK) that carries no retrieval signal on its own. Retrievers skip these so a match on a common word alone does not trigger a false positive.

func IsUUIDv7 added in v0.0.11

func IsUUIDv7(s string) bool

IsUUIDv7 reports whether s is a canonical lowercase UUIDv7 — the shape UUIDv7 mints, version nibble pinned — so callers may order-compare only ids the timestamp layout actually sorts. An arbitrary foreign string must not win "newer" just because it happens to sort high.

func Tokenize

func Tokenize(s string) map[string]struct{}

Tokenize splits text into lowercase word tokens for lexical matching: runs of Latin letters/digits become one token, and each CJK ideograph stands alone (Chinese has no word boundaries, so single ideographs give the overlap signal needed for short-entry retrieval). It is a retrieval heuristic, not a linguistic tokenizer.

func UUIDv7

func UUIDv7() (string, error)

UUIDv7 returns a time-ordered 128-bit identifier per RFC 9562.

Layout: 48-bit Unix millisecond timestamp | 0b0111 (version) | 12 random bits | 0b10 (variant) | 62 random bits. Values sort lexically by creation time, which keeps task rows append-friendly. Uniqueness comes from 74 random bits, sufficient for the idempotency-key use case in this system.

func WriteFileAtomic

func WriteFileAtomic(path string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data to path atomically: the content goes to a temp file in the same directory, is fsynced, and then renamed over path (P1-20). An in-place os.WriteFile leaves a truncated file behind when the process dies mid-write; a same-directory rename is atomic on POSIX and Windows, so readers only ever see the old or the new content, never a torn mix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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