db

package
v0.0.0-...-188825c Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package db provides a database to store information about packages

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPackageNotFound is returned when a package is not found
	ErrPackageNotFound = fmt.Errorf("package not found")
)

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option is a function that sets an option on a PackagesDB

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout for opening the database

type Package

type Package struct {
	Name    string
	Version string

	InstallerVersion string
}

Package represents a package

type PackagesDB

type PackagesDB struct {
	// contains filtered or unexported fields
}

PackagesDB is a database that stores information about packages

func New

func New(dbPath string, opts ...Option) (*PackagesDB, error)

New creates a new PackagesDB

func (*PackagesDB) Close

func (p *PackagesDB) Close() error

Close closes the database

func (*PackagesDB) DeletePackage

func (p *PackagesDB) DeletePackage(name string) error

DeletePackage deletes a package by name

func (*PackagesDB) GetPackage

func (p *PackagesDB) GetPackage(name string) (Package, error)

GetPackage returns a package by name

func (*PackagesDB) HasPackage

func (p *PackagesDB) HasPackage(name string) (bool, error)

HasPackage checks if a package exists

func (*PackagesDB) ListPackages

func (p *PackagesDB) ListPackages() ([]Package, error)

ListPackages returns a list of all packages

func (*PackagesDB) SetPackage

func (p *PackagesDB) SetPackage(pkg Package) error

SetPackage sets a package

Jump to

Keyboard shortcuts

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