aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCatalinStratu <catalinstratu45@gmail.com>2022-05-05 08:53:05 +0300
committerCatalinStratu <catalinstratu45@gmail.com>2022-05-05 09:38:41 +0300
commit661532d2528a190b247913571b38ab47334b1398 (patch)
tree5ee172580403301d7e9e541c7585bc601b3ec9bf /examples
parentb9aecfb8165322e061a1a31260b3ef9199cbebd4 (diff)
downloadspdx-tools-661532d2528a190b247913571b38ab47334b1398.tar.gz
YAML and JSON documenttion fixes
Signed-off-by: CatalinStratu <catalinstratu45@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/11-yamltotv/exampleyamltotv.go15
-rw-r--r--examples/12-tvtoyaml/exampletvtoyaml.go4
-rw-r--r--examples/8-jsontotv/examplejsontotv.go2
-rw-r--r--examples/9-tvtojson/exampletvtojson.go4
-rw-r--r--examples/README.md2
5 files changed, 11 insertions, 16 deletions
diff --git a/examples/11-yamltotv/exampleyamltotv.go b/examples/11-yamltotv/exampleyamltotv.go
index 88f2885..b56a67d 100644
--- a/examples/11-yamltotv/exampleyamltotv.go
+++ b/examples/11-yamltotv/exampleyamltotv.go
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
-// Example for: *yaml*
+// Example for: *yaml* *tvsaver*
// This example demonstrates loading an SPDX tag-value file from disk into memory,
// and re-saving it to a different file on disk.
@@ -10,6 +10,7 @@ package main
import (
"fmt"
+ "github.com/spdx/tools-golang/tvsaver"
"github.com/spdx/tools-golang/yaml"
"os"
)
@@ -20,7 +21,7 @@ func main() {
args := os.Args
if len(args) != 3 {
fmt.Printf("Usage: %v <yaml-file-in> <spdx-file-out>\n", args[0])
- fmt.Printf(" Load SPDX 2.2 tag-value file <yaml-file-in>, and\n")
+ fmt.Printf(" Load YAML file <yaml-file-in>, and\n")
fmt.Printf(" save it out to <spdx-file-out>.\n")
return
}
@@ -34,7 +35,7 @@ func main() {
}
defer r.Close()
- // try to load the SPDX file's contents as a yaml file, version 2.2
+ // try to load the SPDX file's contents as a YAML file
doc, err := spdx_yaml.Load2_2(r)
if err != nil {
fmt.Printf("Error while parsing %v: %v", fileIn, err)
@@ -56,18 +57,12 @@ func main() {
defer w.Close()
// try to save the document to disk as an SPDX tag-value file, version 2.2
- err = spdx_yaml.Save2_2(doc, w)
+ err = tvsaver.Save2_2(doc, w)
if err != nil {
fmt.Printf("Error while saving %v: %v", fileOut, err)
return
}
- //err = tvsaver.Save2_2(doc, w)
- //if err != nil {
- // fmt.Printf("Error while saving %v: %v", fileOut, err)
- // return
- //}
-
// it worked
fmt.Printf("Successfully saved %s\n", fileOut)
}
diff --git a/examples/12-tvtoyaml/exampletvtoyaml.go b/examples/12-tvtoyaml/exampletvtoyaml.go
index 93cd2b0..1f43a03 100644
--- a/examples/12-tvtoyaml/exampletvtoyaml.go
+++ b/examples/12-tvtoyaml/exampletvtoyaml.go
@@ -45,7 +45,7 @@ func main() {
// if we got here, the file is now loaded into memory.
fmt.Printf("Successfully loaded %s\n", args[1])
- // we can now save it back to disk, using jsonsaver.
+ // we can now save it back to disk, using yaml.
// create a new file for writing
fileOut := args[2]
@@ -56,7 +56,7 @@ func main() {
}
defer w.Close()
- // try to save the document to disk as an SPDX json file, version 2.2
+ // try to save the document to disk as an YAML file
err = spdx_yaml.Save2_2(doc, w)
if err != nil {
fmt.Printf("Error while saving %v: %v", fileOut, err)
diff --git a/examples/8-jsontotv/examplejsontotv.go b/examples/8-jsontotv/examplejsontotv.go
index edace80..85be282 100644
--- a/examples/8-jsontotv/examplejsontotv.go
+++ b/examples/8-jsontotv/examplejsontotv.go
@@ -21,7 +21,7 @@ func main() {
args := os.Args
if len(args) != 3 {
fmt.Printf("Usage: %v <json-file-in> <spdx-file-out>\n", args[0])
- fmt.Printf(" Load SPDX 2.2 tag-value file <json-file-in>, and\n")
+ fmt.Printf(" Load JSON file <json-file-in>, and\n")
fmt.Printf(" save it out to <spdx-file-out>.\n")
return
}
diff --git a/examples/9-tvtojson/exampletvtojson.go b/examples/9-tvtojson/exampletvtojson.go
index f7b776f..e8e6937 100644
--- a/examples/9-tvtojson/exampletvtojson.go
+++ b/examples/9-tvtojson/exampletvtojson.go
@@ -22,7 +22,7 @@ func main() {
if len(args) != 3 {
fmt.Printf("Usage: %v <spdx-file-in> <json-file-out>\n", args[0])
fmt.Printf(" Load SPDX 2.2 tag-value file <spdx-file-in>, and\n")
- fmt.Printf(" save it out to <json-file-out>.\n")
+ fmt.Printf(" save it out to JSON <json-file-out>.\n")
return
}
@@ -56,7 +56,7 @@ func main() {
}
defer w.Close()
- // try to save the document to disk as an SPDX json file, version 2.2
+ // try to save the document to disk as JSON file
err = spdx_json.Save2_2(doc, w)
if err != nil {
fmt.Printf("Error while saving %v: %v", fileOut, err)
diff --git a/examples/README.md b/examples/README.md
index 6a312c3..cb8d913 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -97,7 +97,7 @@ and then logging some of the attributes to the console.
## 11-yamltotv
-*yaml*
+*yaml* *tvsaver*
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.