• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spdx / tools-golang / 10193235292

01 Aug 2024 06:28AM UTC coverage: 54.995% (-40.5%) from 95.483%
10193235292

Pull #247

github

kzantow
chore: require go 1.20

Signed-off-by: Keith Zantow <kzantow@gmail.com>
Pull Request #247: feat: prototype v3_0 model

504 of 6474 new or added lines in 3 files covered. (7.78%)

4 existing lines in 1 file now uncovered.

7712 of 14023 relevant lines covered (55.0%)

12.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/convert/chain.go
1
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
2

3
package convert
4

5
import (
6
        "fmt"
7
        "reflect"
8

9
        converter "github.com/anchore/go-struct-converter"
10

11
        "github.com/spdx/tools-golang/spdx/common"
12
        "github.com/spdx/tools-golang/spdx/v2/v2_1"
13
        "github.com/spdx/tools-golang/spdx/v2/v2_2"
14
        "github.com/spdx/tools-golang/spdx/v2/v2_3"
15
)
16

17
var DocumentChain = converter.NewChain(
18
        v2_1.Document{},
19
        v2_2.Document{},
20
        v2_3.Document{},
21
)
22

23
// Document converts from one document to another document
24
// For example, converting a document to the latest version could be done like:
25
//
26
// sourceDoc := // e.g. a v2_2.Document from somewhere
27
// var targetDoc spdx.Document // this can be any document version
28
// err := convert.Document(sourceDoc, &targetDoc) // the target must be passed as a pointer
29
func Document(from common.AnyDocument, to common.AnyDocument) error {
3✔
30
        if !IsPtr(to) {
3✔
UNCOV
31
                return fmt.Errorf("struct to convert to must be a pointer")
×
UNCOV
32
        }
×
33
        from = FromPtr(from)
3✔
34
        if reflect.TypeOf(from) == reflect.TypeOf(FromPtr(to)) {
3✔
35
                reflect.ValueOf(to).Elem().Set(reflect.ValueOf(from))
×
UNCOV
36
                return nil
×
UNCOV
37
        }
×
38
        return DocumentChain.Convert(from, to)
3✔
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc