binary

package
v1.40.5 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Original source by syft https://github.com/anchore/syft/blob/c53f2fbad369b7c19d28b3b63511c95a04e33ff1/internal/regex_helpers.go#L1

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnrecognizedExe = xerrors.New("unrecognized executable format")
	ErrNonGoBinary     = xerrors.New("non go binary")
)

Functions

func MatchAnyFromReader

func MatchAnyFromReader(r io.Reader, res ...*regexp.Regexp) (bool, error)

MatchAnyFromReader matches any of the provided regular expressions from a reader, assuming the pattern fits within 1.5x the reader chunk size (1MB * 1.5).

func MatchNamedCaptureGroups

func MatchNamedCaptureGroups(regEx *regexp.Regexp, content string) map[string]string

MatchNamedCaptureGroups takes a regular expression and string and returns all of the named capture group results in a map. This is only for the first match in the regex. Callers shouldn't be providing regexes with multiple capture groups with the same name.

func MatchNamedCaptureGroupsFromReader

func MatchNamedCaptureGroupsFromReader(re *regexp.Regexp, r io.Reader) (map[string]string, error)

MatchNamedCaptureGroupsFromReader matches named capture groups from a reader, assuming the pattern fits within 1.5x the reader chunk size (1MB * 1.5).

Types

type Parser

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

func NewParser

func NewParser() *Parser

func (*Parser) Parse

Parse scans file to try to report the Go and module versions.

func (*Parser) ParseLDFlags

func (p *Parser) ParseLDFlags(name string, flags []string) string

ParseLDFlags attempts to parse the binary's version from any `-ldflags` passed to `go build` at build time.

Jump to

Keyboard shortcuts

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