modulepackage
0.1.3
Repository: https://github.com/package-url/packageurl-go.git
Documentation: pkg.go.dev
# README
packageurl-go
Go implementation of the package url spec.
Install
go get -u github.com/package-url/packageurl-go
Versioning
The versions will follow the spec. So if the spec is released at 1.0
. Then all versions in the 1.x.y
will follow the 1.x
spec.
Usage
Create from parts
package main
import (
"fmt"
"github.com/package-url/packageurl-go"
)
func main() {
instance := packageurl.NewPackageURL("test", "ok", "name", "version", nil, "")
fmt.Printf("%s", instance.ToString())
}
Parse from string
package main
import (
"fmt"
"github.com/package-url/packageurl-go"
)
func main() {
instance, err := packageurl.FromString("test:ok/name@version")
if err != nil {
panic(err)
}
fmt.Printf("%#v", instance)
}
Test
Testing using the normal go test
command. Using make test
will pull the test fixtures shared between all package-url projects and then execute the tests.
curl -Ls https://raw.githubusercontent.com/package-url/purl-spec/master/test-suite-data.json -o testdata/test-suite-data.json
go test -v -cover ./...
=== RUN TestFromStringExamples
--- PASS: TestFromStringExamples (0.00s)
=== RUN TestToStringExamples
--- PASS: TestToStringExamples (0.00s)
=== RUN TestStringer
--- PASS: TestStringer (0.00s)
=== RUN TestQualifiersMapConversion
--- PASS: TestQualifiersMapConversion (0.00s)
PASS
github.com/package-url/packageurl-go coverage: 90.7% of statements
ok github.com/package-url/packageurl-go 0.004s coverage: 90.7% of statements
Fuzzing
Fuzzing is done with standard Go fuzzing, introduced in Go 1.18.
Fuzz tests check for inputs that cause FromString
to panic.
Using make fuzz
will run fuzz tests for one minute.
To run fuzz tests longer:
go test -fuzztime=60m -fuzz .
Or omit -fuzztime
entirely to run indefinitely.
# Functions
FromString parses a valid package url string into a PackageURL structure.
NewPackageURL creates a new PackageURL struct instance based on input.
QualifiersFromMap constructs a Qualifiers slice from a string map.
# Variables
CandidateTypes is a map of types that are not yet officially supported by the spec, but are being considered for inclusion.
KnownTypes is a map of types that are officially supported by the spec.
QualifierKeyPattern describes a valid qualifier key:
- The key must be composed only of ASCII letters and numbers, '.', '-' and '_' (period, dash and underscore).
TypeAlpm is a pkg:alpm purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeApk is a pkg:apk purl.
These are the known purl types as defined in the spec.
TypeBitbucket is a pkg:bitbucket purl.
TypeBitnami is a pkg:bitnami purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeCargo is a pkg:cargo purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeCocoapods is a pkg:cocoapods purl.
TypeComposer is a pkg:composer purl.
TypeConan is a pkg:conan purl.
TypeConda is a pkg:conda purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeCran is a pkg:cran purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeDebian is a pkg:deb purl.
TypeDocker is a pkg:docker purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeGem is a pkg:gem purl.
TypeGeneric is a pkg:generic purl.
These are the known purl types as defined in the spec.
TypeGithub is a pkg:github purl.
These are the known purl types as defined in the spec.
TypeGolang is a pkg:golang purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeHackage is a pkg:hackage purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeHex is a pkg:hex purl.
TypeHuggingface is pkg:huggingface purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeMaven is a pkg:maven purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeMLflow is pkg:mlflow purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeNPM is a pkg:npm purl.
TypeNuget is a pkg:nuget purl.
TypeOCI is a pkg:oci purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypePattern describes a valid type:
- The type must be composed only of ASCII letters and numbers, '.', '+' and '-' (period, plus and dash).
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypePub is a pkg:pub purl.
These are the known purl types as defined in the spec.
TypePyPi is a pkg:pypi purl.
TypeQPKG is a pkg:qpkg purl.
TypeRPM is a pkg:rpm purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
TypeSWID is pkg:swid purl.
TypeSwift is pkg:swift purl.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
These are the known purl types as defined in the spec.
# Structs
PackageURL is the struct representation of the parts that make a package url.
Qualifier represents a single key=value qualifier in the package url.
# Type aliases
Qualifiers is a slice of key=value pairs, with order preserved as it appears in the package URL.