SPDX-License-Identifier: CC-BY-4.0
The examples/
directory contains examples for how to use the various
tools-golang sub-packages. Sample commands below should be run from
within the example's subdirectory.
tagvalue, spdx
This example demonstrates loading an SPDX tag-value file from disk into memory, and printing some of its contents to standard output.
tagvalue, tagvalue
This example demonstrates loading an SPDX tag-value file from disk into memory, and re-saving it to a different file on disk.
builder, tagvalue
This example demonstrates building an 'empty' SPDX document in memory that corresponds to a given directory's contents, including all files with their hashes and the package's verification code, and saving the document to disk.
idsearcher, tagvalue
This example demonstrates building an SPDX document for a directory's contents (implicitly using builder); searching through that directory for SPDX short-form IDs; filling those IDs into the document's Package and File license fields; and saving the resulting document to disk.
reporter, tagvalue
This example demonstrates loading an SPDX tag-value file from disk into memory, generating a basic report listing counts of the concluded licenses for its files, and printing the report to standard output.
licensediff, tagvalue
This example demonstrates loading two SPDX tag-value files from disk into memory, and generating a diff of the concluded licenses for Files in Packages with matching IDs in each document.
This is generally only useful when run with two SPDX documents that describe licenses for subsequent versions of the same set of files, AND if they have the same identifier in both documents.
Run project: go run example_licensediff.go ../sample-docs/tv/hello.spdx ../sample-docs/tv/hello-modified.spdx
rdfloader, spdx
This example demonstrates loading an SPDX rdf file from disk into memory and then printing the corresponding spdx struct for the document.
json, tagvalue
This example demonstrates loading an SPDX json from disk into memory and then re-saving it to a different file on disk in tag-value format.
Run project: go run examplejsontotv.go ../sample-docs/json/SPDXJSONExample-v2.2.spdx.json example.spdx
json, tagvalue
This example demonstrates loading an SPDX tag-value from disk into memory and then re-saving it to a different file on disk in json format.
json
This example demonstrates loading an SPDX json from disk into memory and then logging some of the attributes to the console.
yaml tagvalue
This example demonstrates loading an SPDX yaml from disk into memory and then re-saving it to a different file on disk in tag-value format.
yaml tagvalue
This example demonstrates loading an SPDX tag-value from disk into memory and then re-saving it to a different file on disk in yaml format.
yaml
This example demonstrates loading an SPDX yaml from disk into memory and then logging some of the attributes to the console.