-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.go
44 lines (34 loc) · 810 Bytes
/
result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package license
import (
"bytes"
"fmt"
"github.com/0xDaoChain/dao-chain/licenses"
)
type LicenseResult struct {
BSDLicenses []licenses.DepLicense `json:"bsd_licenses"`
}
func (r *LicenseResult) GetOutput() string {
var buffer bytes.Buffer
buffer.WriteString("\n[LICENSE]\n\n")
buffer.WriteString(licenses.License)
buffer.WriteString("\n[DEPENDENCY ATTRIBUTIONS]\n\n")
for idx, l := range r.BSDLicenses {
// put a blank line between attributions
if idx != 0 {
buffer.WriteString("\n")
}
name := l.Name
if l.Version != nil {
name += " " + *l.Version
}
buffer.WriteString(fmt.Sprintf(
" This product bundles %s,\n"+
" which is available under a \"%s\" license.\n"+
" For details, see %s.\n",
name,
l.Type,
l.Path,
))
}
return buffer.String()
}