Skip to content

Scalar, aggregate & collation extensions

These add SQL functions, operators, and collations. Blank-import the /auto package and they show up in any Where / Order / Select:

import (
_ "gosqlite.org/ext/hash/auto"
_ "gosqlite.org/ext/regexp/auto"
_ "gosqlite.org/ext/uuid/auto"
)
db.Where("email REGEXP ?", `^.*@example\.com$`).Find(&users)
db.Select(`hex(sha256(body)) AS digest`).Find(&logs)
db.Where("ipcontains(?, src_ip)", "10.0.0.0/8").Find(&events)
PackageWhat it adds
regexpRE2 REGEXP operator + regexp_* scalars
uuiduuid() v1–v7 (incl. DCE v2) + uuid_str / uuid_blob + extractors
hashmd5 / sha1 / sha256 / sha512 / sha3 / blake2b / blake3 / xxh64
ipaddripcontains / ipfamily / ipnetwork over net/netip
zorderMorton (Z-order) encoding for 2–24 dimensions
statsvariance / percentile / regr_* / median / mode aggregates + sliding-window inverses
unicodeUnicode-aware upper / lower / normalize / unaccent + NOCASE_UNICODE collation + locale collators
encodeencode / decode — base64 / base32 / base16 / ascii85 / url
textrune-aware text_reverse / text_repeat / text_lpad / text_rpad / text_split
fuzzylevenshtein / damerau_levenshtein / hamming / jaro / jaro_winkler / soundex / caverphone
decimalexact base-10 decimal_add/sub/mul/div/round/… + decimal_sum aggregate (math/big)
moneyfixed-2dp currency + money_format
timetime_unix / add / diff / part / trunc / format over Go time
evaleval(sql[, sep]) runs dynamic SQL on the calling connection (trusted input only)

Runnable demos under examples/features/extensions/ (e.g. hash, fuzzy, extras for decimal/money/time/eval). End-to-end against a gorm model: examples/features/gorm/ext-scalars/.