core

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package core provides shared types and the parser registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyMatch

func AnyMatch(matchers ...func(string) bool) func(string) bool

AnyMatch returns a matcher that matches if any of the given matchers match.

func EstimateDeps

func EstimateDeps(size int) int

EstimateDeps estimates the number of dependencies based on file size.

func ExactMatch

func ExactMatch(names ...string) func(string) bool

ExactMatch returns a matcher for exact filename matches.

func ExtractQuotedValue

func ExtractQuotedValue(line, prefix string) (string, bool)

ExtractQuotedValue extracts value from lines like: key = "value"

func ForEachLine

func ForEachLine(content string, fn func(line string) bool)

ForEachLine iterates over lines in content without allocating a slice.

func GlobMatch

func GlobMatch(pattern string) func(string) bool

GlobMatch returns a matcher for glob pattern matches.

func IdentifyParser

func IdentifyParser(filename string) (Parser, string, Kind)

IdentifyParser returns the first matching parser for a filename.

func ParseDockerImage

func ParseDockerImage(image string) (name, version string)

ParseDockerImage parses a Docker image reference like "nginx:1.19" or "nginx@sha256:abc". When both tag and digest are present (nginx:1.19@sha256:abc), the digest is used as version and the tag is stripped from the name.

func PrefixMatch

func PrefixMatch(prefixes ...string) func(string) bool

PrefixMatch returns a matcher for prefix matches.

func Register

func Register(ecosystem string, kind Kind, parser Parser, match func(string) bool)

Register adds a parser to the registry.

func SuffixMatch

func SuffixMatch(suffixes ...string) func(string) bool

SuffixMatch returns a matcher for suffix matches.

func SupportedEcosystems

func SupportedEcosystems() []string

SupportedEcosystems returns all registered ecosystem types.

Types

type Dependency

type Dependency struct {
	Name        string
	Version     string
	Scope       Scope
	Integrity   string
	Direct      bool
	PURL        string
	RegistryURL string
}

Dependency represents a parsed dependency from a manifest or lockfile.

type Kind

type Kind string

Kind distinguishes manifest files from lockfiles.

const (
	Manifest   Kind = "manifest"
	Lockfile   Kind = "lockfile"
	Supplement Kind = "supplement"
)

type Match

type Match struct {
	Ecosystem string
	Kind      Kind
}

Match represents a file type match.

func IdentifyAllParsers

func IdentifyAllParsers(filename string) []Match

IdentifyAllParsers returns all matching parsers for a filename.

type ParseError

type ParseError struct {
	Filename string
	Err      error
}

ParseError is returned when parsing fails.

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type Parser

type Parser interface {
	Parse(filename string, content []byte) ([]Dependency, error)
}

Parser is the interface implemented by all manifest parsers.

type Registration

type Registration struct {
	Ecosystem string
	Kind      Kind
	Parser    Parser
	Match     func(filename string) bool
}

Registration holds parser metadata.

type Scope

type Scope string

Scope indicates when a dependency is required.

const (
	Runtime     Scope = "runtime"
	Development Scope = "development"
	Test        Scope = "test"
	Build       Scope = "build"
	Optional    Scope = "optional"
)

Jump to

Keyboard shortcuts

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