aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSteve Winslow <steve@swinslow.net>2020-06-14 16:00:56 -0400
committerSteve Winslow <steve@swinslow.net>2020-06-14 16:00:56 -0400
commitd1b825c0905735029cfa9b4d54057a350fe32d66 (patch)
tree6b398993765df4934fe21997a13a23f6150cd136 /examples
parent1e75edca9522aa82d1f269929d907209f93b3575 (diff)
downloadspdx-tools-d1b825c0905735029cfa9b4d54057a350fe32d66.tar.gz
Update examples to 2.2
Signed-off-by: Steve Winslow <steve@swinslow.net>
Diffstat (limited to 'examples')
-rw-r--r--examples/1-load/example_load.go8
-rw-r--r--examples/2-load-save/example_load_save.go10
-rw-r--r--examples/3-build/example_build.go10
-rw-r--r--examples/4-search/example_search.go14
-rw-r--r--examples/5-report/example_report.go10
-rw-r--r--examples/6-licensediff/example_licensediff.go16
6 files changed, 34 insertions, 34 deletions
diff --git a/examples/1-load/example_load.go b/examples/1-load/example_load.go
index e2af1ac..2ad0a0b 100644
--- a/examples/1-load/example_load.go
+++ b/examples/1-load/example_load.go
@@ -21,7 +21,7 @@ func main() {
args := os.Args
if len(args) != 2 {
fmt.Printf("Usage: %v <spdx-file-in>\n", args[0])
- fmt.Printf(" Load SPDX 2.1 tag-value file <spdx-file-in>, and\n")
+ fmt.Printf(" Load SPDX 2.2 tag-value file <spdx-file-in>, and\n")
fmt.Printf(" print a portion of its contents.\n")
return
}
@@ -35,8 +35,8 @@ func main() {
}
defer r.Close()
- // try to load the SPDX file's contents as a tag-value file, version 2.1
- doc, err := tvloader.Load2_1(r)
+ // try to load the SPDX file's contents as a tag-value file, version 2.2
+ doc, err := tvloader.Load2_2(r)
if err != nil {
fmt.Printf("Error while parsing %v: %v", filename, err)
return
@@ -55,7 +55,7 @@ func main() {
fmt.Printf("%#v\n\n", doc.CreationInfo)
// check whether the SPDX file has at least one package that it describes
- pkgIDs, err := spdxlib.GetDescribedPackageIDs2_1(doc)
+ pkgIDs, err := spdxlib.GetDescribedPackageIDs2_2(doc)
if err != nil {
fmt.Printf("Unable to get describe packages from SPDX document: %v\n", err)
return
diff --git a/examples/2-load-save/example_load_save.go b/examples/2-load-save/example_load_save.go
index 39ab501..0abb89c 100644
--- a/examples/2-load-save/example_load_save.go
+++ b/examples/2-load-save/example_load_save.go
@@ -21,7 +21,7 @@ func main() {
args := os.Args
if len(args) != 3 {
fmt.Printf("Usage: %v <spdx-file-in> <spdx-file-out>\n", args[0])
- fmt.Printf(" Load SPDX 2.1 tag-value file <spdx-file-in>, and\n")
+ fmt.Printf(" Load SPDX 2.2 tag-value file <spdx-file-in>, and\n")
fmt.Printf(" save it out to <spdx-file-out>.\n")
return
}
@@ -35,8 +35,8 @@ func main() {
}
defer r.Close()
- // try to load the SPDX file's contents as a tag-value file, version 2.1
- doc, err := tvloader.Load2_1(r)
+ // try to load the SPDX file's contents as a tag-value file, version 2.2
+ doc, err := tvloader.Load2_2(r)
if err != nil {
fmt.Printf("Error while parsing %v: %v", fileIn, err)
return
@@ -56,8 +56,8 @@ func main() {
}
defer w.Close()
- // try to save the document to disk as an SPDX tag-value file, version 2.1
- err = tvsaver.Save2_1(doc, w)
+ // try to save the document to disk as an SPDX tag-value file, version 2.2
+ err = tvsaver.Save2_2(doc, w)
if err != nil {
fmt.Printf("Error while saving %v: %v", fileOut, err)
return
diff --git a/examples/3-build/example_build.go b/examples/3-build/example_build.go
index 64d6eb0..cc63bb7 100644
--- a/examples/3-build/example_build.go
+++ b/examples/3-build/example_build.go
@@ -22,7 +22,7 @@ func main() {
args := os.Args
if len(args) != 4 {
fmt.Printf("Usage: %v <package-name> <package-root-dir> <spdx-file-out>\n", args[0])
- fmt.Printf(" Build a SPDX 2.1 document with one package called <package-name>;\n")
+ fmt.Printf(" Build a SPDX 2.2 document with one package called <package-name>;\n")
fmt.Printf(" create files with hashes corresponding to the files in <package-root-dir>;\n")
fmt.Printf(" and save it out as a tag-value file to <spdx-file-out>.\n")
return
@@ -34,9 +34,9 @@ func main() {
fileOut := args[3]
// to use the SPDX builder package, the first step is to define a
- // builder.Config2_1 struct. this config data can be reused, in case you
+ // builder.Config2_2 struct. this config data can be reused, in case you
// are building SPDX documents for several directories in sequence.
- config := &builder.Config2_1{
+ config := &builder.Config2_2{
// NamespacePrefix is a prefix that will be used to populate the
// mandatory DocumentNamespace field in the Creation Info section.
@@ -86,7 +86,7 @@ func main() {
// - what to name the package; and
// - where the directory is located on disk; and
// - the config object we just defined.
- doc, err := builder.Build2_1(packageName, packageRootDir, config)
+ doc, err := builder.Build2_2(packageName, packageRootDir, config)
if err != nil {
fmt.Printf("Error while building document: %v\n", err)
return
@@ -107,7 +107,7 @@ func main() {
}
defer w.Close()
- err = tvsaver.Save2_1(doc, w)
+ err = tvsaver.Save2_2(doc, w)
if err != nil {
fmt.Printf("Error while saving %v: %v", fileOut, err)
return
diff --git a/examples/4-search/example_search.go b/examples/4-search/example_search.go
index 4a983e4..f7b91ba 100644
--- a/examples/4-search/example_search.go
+++ b/examples/4-search/example_search.go
@@ -25,7 +25,7 @@ func main() {
args := os.Args
if len(args) != 4 {
fmt.Printf("Usage: %v <package-name> <package-root-dir> <spdx-file-out>\n", args[0])
- fmt.Printf(" Build a SPDX 2.1 document with one package called <package-name>;\n")
+ fmt.Printf(" Build a SPDX 2.2 document with one package called <package-name>;\n")
fmt.Printf(" create files with hashes corresponding to the files in <package-root-dir>;\n")
fmt.Printf(" search for SPDX short-form IDs, and use them to fill in license data\n")
fmt.Printf(" where possible; and save it out as a tag-value file to <spdx-file-out>.\n")
@@ -38,9 +38,9 @@ func main() {
fileOut := args[3]
// to use the SPDX idsearcher package, the first step is to define a
- // idsearcher.Config2_1 struct. this config data can be reused, in case you
+ // idsearcher.Config2_2 struct. this config data can be reused, in case you
// are building SPDX documents for several directories in sequence.
- config := &idsearcher.Config{
+ config := &idsearcher.Config2_2{
// NamespacePrefix is a prefix that will be used to populate the
// mandatory DocumentNamespace field in the Creation Info section.
@@ -49,8 +49,8 @@ func main() {
// appended to this prefix.
NamespacePrefix: "https://example.com/whatever/testdata-",
- // CreatorType and Creator, from builder.Config2_1, are not needed for
- // idsearcher.Config. Because it is automated and doesn't assume
+ // CreatorType and Creator, from builder.Config2_2, are not needed for
+ // idsearcher.Config2_2. Because it is automated and doesn't assume
// further review, the following two Creator fields are filled in:
// Creator: Tool: github.com/spdx/tools-golang/builder
// Creator: Tool: github.com/spdx/tools-golang/idsearcher
@@ -109,7 +109,7 @@ func main() {
// these are the same arguments needed for builder, and in fact they get
// passed through to builder (with the relevant data from the config
// object extracted behind the scenes).
- doc, err := idsearcher.BuildIDsDocument(packageName, packageRootDir, config)
+ doc, err := idsearcher.BuildIDsDocument2_2(packageName, packageRootDir, config)
if err != nil {
fmt.Printf("Error while building document: %v\n", err)
return
@@ -138,7 +138,7 @@ func main() {
}
defer w.Close()
- err = tvsaver.Save2_1(doc, w)
+ err = tvsaver.Save2_2(doc, w)
if err != nil {
fmt.Printf("Error while saving %v: %v", fileOut, err)
return
diff --git a/examples/5-report/example_report.go b/examples/5-report/example_report.go
index e4250be..4464f07 100644
--- a/examples/5-report/example_report.go
+++ b/examples/5-report/example_report.go
@@ -23,7 +23,7 @@ func main() {
args := os.Args
if len(args) != 2 {
fmt.Printf("Usage: %v <spdx-file-in>\n", args[0])
- fmt.Printf(" Load SPDX 2.1 tag-value file <spdx-file-in>, and\n")
+ fmt.Printf(" Load SPDX 2.2 tag-value file <spdx-file-in>, and\n")
fmt.Printf(" generate and print a report of its concluded licenses.\n")
return
}
@@ -37,8 +37,8 @@ func main() {
}
defer r.Close()
- // try to load the SPDX file's contents as a tag-value file, version 2.1
- doc, err := tvloader.Load2_1(r)
+ // try to load the SPDX file's contents as a tag-value file, version 2.2
+ doc, err := tvloader.Load2_2(r)
if err != nil {
fmt.Printf("Error while parsing %v: %v", filename, err)
return
@@ -48,7 +48,7 @@ func main() {
fmt.Printf("Successfully loaded %s\n\n", filename)
// check whether the SPDX file has at least one package that it describes
- pkgIDs, err := spdxlib.GetDescribedPackageIDs2_1(doc)
+ pkgIDs, err := spdxlib.GetDescribedPackageIDs2_2(doc)
if err != nil {
fmt.Printf("Unable to get describe packages from SPDX document: %v\n", err)
return
@@ -79,7 +79,7 @@ func main() {
// values, sorted by # of occurrences
fmt.Printf("============================\n")
fmt.Printf("Package %s (%s)\n", string(pkgID), pkg.PackageName)
- err = reporter.Generate(pkg, os.Stdout)
+ err = reporter.Generate2_2(pkg, os.Stdout)
if err != nil {
fmt.Printf("Error while generating report: %v\n", err)
}
diff --git a/examples/6-licensediff/example_licensediff.go b/examples/6-licensediff/example_licensediff.go
index 567c909..057e95e 100644
--- a/examples/6-licensediff/example_licensediff.go
+++ b/examples/6-licensediff/example_licensediff.go
@@ -26,7 +26,7 @@ func main() {
args := os.Args
if len(args) != 3 {
fmt.Printf("Usage: %v <spdx-file-first> <spdx-file-second>\n", args[0])
- fmt.Printf(" Load SPDX 2.1 tag-value files <spdx-file-first> and <spdx-file-second>,\n")
+ fmt.Printf(" Load SPDX 2.2 tag-value files <spdx-file-first> and <spdx-file-second>,\n")
fmt.Printf(" run a diff between their concluded licenses, and print basic results.\n")
return
}
@@ -40,14 +40,14 @@ func main() {
}
defer r.Close()
- // try to load the first SPDX file's contents as a tag-value file, version 2.1
- docFirst, err := tvloader.Load2_1(r)
+ // try to load the first SPDX file's contents as a tag-value file, version 2.2
+ docFirst, err := tvloader.Load2_2(r)
if err != nil {
fmt.Printf("Error while parsing %v: %v", filenameFirst, err)
return
}
// check whether the SPDX file has at least one package that it describes
- pkgIDsFirst, err := spdxlib.GetDescribedPackageIDs2_1(docFirst)
+ pkgIDsFirst, err := spdxlib.GetDescribedPackageIDs2_2(docFirst)
if err != nil {
fmt.Printf("Unable to get describe packages from first SPDX document: %v\n", err)
return
@@ -65,14 +65,14 @@ func main() {
}
defer r.Close()
- // try to load the second SPDX file's contents as a tag-value file, version 2.1
- docSecond, err := tvloader.Load2_1(r)
+ // try to load the second SPDX file's contents as a tag-value file, version 2.2
+ docSecond, err := tvloader.Load2_2(r)
if err != nil {
fmt.Printf("Error while parsing %v: %v", filenameSecond, err)
return
}
// check whether the SPDX file has at least one package that it describes
- pkgIDsSecond, err := spdxlib.GetDescribedPackageIDs2_1(docSecond)
+ pkgIDsSecond, err := spdxlib.GetDescribedPackageIDs2_2(docSecond)
if err != nil {
fmt.Printf("Unable to get describe packages from second SPDX document: %v\n", err)
return
@@ -98,7 +98,7 @@ func main() {
}
// now, run a diff between the two
- pairs, err := licensediff.MakePairs(p1, p2)
+ pairs, err := licensediff.MakePairs2_2(p1, p2)
if err != nil {
fmt.Printf(" Error generating licensediff pairs: %v\n", err)
continue