Help us shape the future of Go! Take the 2026 Go Developer Survey

dbpath

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dbpath names a SQLite database file the one way every handle on it will agree on.

SQLite coordinates the connections to a WAL-mode database through files whose names it derives from the path it was given (the -wal and -shm files, and on Windows the lock identity). Two handles that reach one file by different paths (a symlink, another spelling, a relative path, a different case on a case-insensitive file system, a hard link) can derive different names, each then believes it owns the WAL, and the database is corrupted: https://sqlite.org/howtocorrupt.html ("Multiple links to the same file", "Symlinks"). Canonical gives the path with symlinks resolved and made absolute, which removes every alias but a hard link; a hard link has no canonical name, so Canonical refuses a file with more than one.

Index

Constants

This section is empty.

Variables

View Source
var ErrHardLinked = errors.New("dbpath: the database file has more than one hard link")

ErrHardLinked is wrapped by the error Canonical returns for a file with more than one hard link.

Functions

func Canonical

func Canonical(path string, create bool) (string, error)

Canonical returns path with symlinks resolved and made absolute, keeping any "?query" and "file:" prefix; an in-memory path is returned as is. A file that does not exist is created empty first when create is true (SQLite takes an empty file for a new database, and the file needs to exist to be resolved), and left as the cleaned absolute path otherwise. It fails with an error wrapping ErrHardLinked for a file with more than one hard link.

func CheckLinks(path string) error

CheckLinks returns an error wrapping ErrHardLinked if the file at path has more than one hard link. A file whose links cannot be counted (it does not exist, or the platform cannot say) passes.

func IsMemory

func IsMemory(path string) bool

IsMemory reports whether path names an in-memory or temporary database, which has no file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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