sqlitefile

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sqlitefile secures file-backed SQLite databases before a driver opens them. It deliberately leaves caller-owned parent directory modes alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	Path         string
	FileBacked   bool
	Memory       bool
	SharedMemory bool
	// contains filtered or unexported fields
}

Location is the single canonical interpretation of a SQLite DSN used by filesystem permission and ownership-lock boundaries.

func PreparePrivate

func PreparePrivate(dsn, purpose string) (Location, error)

PreparePrivate creates a file-backed SQLite database with mode 0600, or tightens an existing regular database to that mode. In-memory DSNs need no filesystem preparation. Parent directories must already exist; their modes are never changed.

The returned Location is the only value callers should use for sql.Open and related owner locks. This keeps the permission check, lock, and actual driver open on one canonical absolute path.

func Resolve

func Resolve(dsn string) (Location, error)

Resolve maps a SQLite DSN to one canonical filesystem path. The same result must be used by every permission and single-owner boundary so encoded URI, relative-path, and symlinked-parent aliases cannot acquire separate locks.

func (Location) OpenDSN

func (location Location) OpenDSN() string

OpenDSN returns the canonical DSN that must be passed to sql.Open. For a file-backed database it names Location.Path with an absolute path while retaining the original URI query byte-for-byte. In-memory DSNs are returned unchanged so named and shared-cache memory semantics are preserved.

Jump to

Keyboard shortcuts

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