aboutsummaryrefslogtreecommitdiff
path: root/tvsaver/saver2v1/save_snippet.go
diff options
context:
space:
mode:
authorRishabhBhatnagar <bhatnagarrishabh4@gmail.com>2020-01-09 20:39:55 +0530
committerRishabhBhatnagar <bhatnagarrishabh4@gmail.com>2020-01-09 21:04:37 +0530
commitcd59ee66408a908f7ef94548814514f6bc9fc906 (patch)
tree550b146d4de0cc00a4784147f7d8f2a7bc93cffe /tvsaver/saver2v1/save_snippet.go
parentf4fef41a45620391fca6481f4700b89de170ab88 (diff)
downloadspdx-tools-cd59ee66408a908f7ef94548814514f6bc9fc906.tar.gz
Create Go Module
- Unpack directory v0 to move all the content to the root directory. - ./v0/* converted to ./* - all the test cases were fixed to remove one directory less indexing for test files - add go.mod - go version 1.13 is used to have a relatively stable versioning system Signed-off-by: RishabhBhatnagar <bhatnagarrishabh4@gmail.com>
Diffstat (limited to 'tvsaver/saver2v1/save_snippet.go')
-rw-r--r--tvsaver/saver2v1/save_snippet.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/tvsaver/saver2v1/save_snippet.go b/tvsaver/saver2v1/save_snippet.go
new file mode 100644
index 0000000..d42282b
--- /dev/null
+++ b/tvsaver/saver2v1/save_snippet.go
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+
+package saver2v1
+
+import (
+ "fmt"
+ "io"
+
+ "github.com/spdx/tools-golang/spdx"
+)
+
+func renderSnippet2_1(sn *spdx.Snippet2_1, w io.Writer) error {
+ if sn.SnippetSPDXIdentifier != "" {
+ fmt.Fprintf(w, "SnippetSPDXIdentifier: %s\n", sn.SnippetSPDXIdentifier)
+ }
+ if sn.SnippetFromFileSPDXIdentifier != "" {
+ fmt.Fprintf(w, "SnippetFromFileSPDXID: %s\n", sn.SnippetFromFileSPDXIdentifier)
+ }
+ if sn.SnippetByteRangeStart != 0 && sn.SnippetByteRangeEnd != 0 {
+ fmt.Fprintf(w, "SnippetByteRange: %d:%d\n", sn.SnippetByteRangeStart, sn.SnippetByteRangeEnd)
+ }
+ if sn.SnippetLineRangeStart != 0 && sn.SnippetLineRangeEnd != 0 {
+ fmt.Fprintf(w, "SnippetLineRange: %d:%d\n", sn.SnippetLineRangeStart, sn.SnippetLineRangeEnd)
+ }
+ if sn.SnippetLicenseConcluded != "" {
+ fmt.Fprintf(w, "SnippetLicenseConcluded: %s\n", sn.SnippetLicenseConcluded)
+ }
+ for _, s := range sn.LicenseInfoInSnippet {
+ fmt.Fprintf(w, "LicenseInfoInSnippet: %s\n", s)
+ }
+ if sn.SnippetLicenseComments != "" {
+ fmt.Fprintf(w, "SnippetLicenseComments: %s\n", textify(sn.SnippetLicenseComments))
+ }
+ if sn.SnippetCopyrightText != "" {
+ fmt.Fprintf(w, "SnippetCopyrightText: %s\n", sn.SnippetCopyrightText)
+ }
+ if sn.SnippetComment != "" {
+ fmt.Fprintf(w, "SnippetComment: %s\n", textify(sn.SnippetComment))
+ }
+ if sn.SnippetName != "" {
+ fmt.Fprintf(w, "SnippetName: %s\n", sn.SnippetName)
+ }
+
+ fmt.Fprintf(w, "\n")
+
+ return nil
+}