Documentation ¶
Overview ¶
Package parser exposes methods to decode dependency information from the supported packaging ecosystems.
Index ¶
- func Parse(filename string, content string) ([]types.Dependency, string, error)
- func ParseCargoToml(content string) ([]types.Dependency, error)
- func ParseGoMod(content string) ([]types.Dependency, error)
- func ParsePackageJSON(content string) ([]types.Dependency, error)
- func ParsePomXml(content string) ([]types.Dependency, error)
- func ParseRequirementsTxt(content string) ([]types.Dependency, error)
- type ParsingFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses the given filename and content to extract dependencies and determine the ecosystem. It iterates through the available parsing function based on the file suffix and calls the appropriate function. If a matching parsing function is found, it returns the extracted dependencies, the determined ecosystem, and any error encountered. If no matching parsing function is found, it returns an empty slice of dependencies, "none" as the ecosystem, and no error.
func ParseCargoToml ¶
func ParseCargoToml(content string) ([]types.Dependency, error)
ParseCargoToml parses the content of a Cargo.toml file and returns a slice of dependencies. It takes a string parameter `content` which represents the content of the Cargo.toml file. The function returns a slice of `types.Dependency` and an error if any occurred during parsing.
func ParseGoMod ¶
func ParseGoMod(content string) ([]types.Dependency, error)
ParseGoMod parses the content of a go.mod file and returns a slice of dependencies. Each dependency is represented by a types.Dependency struct, containing the name and version.
func ParsePackageJSON ¶
func ParsePackageJSON(content string) ([]types.Dependency, error)
ParsePackageJSON parses package.json content and extracts dependencies
func ParsePomXml ¶
func ParsePomXml(content string) ([]types.Dependency, error)
ParsePomXml parses the content of a POM XML file and returns a slice of dependencies along with their group ID, artifact ID, and version. The content parameter is the string representation of the POM XML file. The function returns a slice of types.Dependency and an error. If the parsing is successful, the slice of dependencies is populated and the error is nil. If an error occurs during parsing, the function returns nil for the slice of dependencies and the error that occurred.
func ParseRequirementsTxt ¶
func ParseRequirementsTxt(content string) ([]types.Dependency, error)
ParseRequirementsTxt parses requirements.txt content and extracts dependencies
Types ¶
type ParsingFunction ¶
type ParsingFunction func(string) ([]types.Dependency, error)
ParsingFunction is a function type that takes a string as input and returns a slice of dependencies and an error.