Skip to content

Commit 4f63854

Browse files
committed
docs: update docs to include extract licenses
1 parent 7fe1a57 commit 4f63854

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,30 @@ assert.True(valid)
131131
assert.NotContains(invalidLicenses, "MIT AND APACHE-2.0")
132132
```
133133

134+
### ExtractLicenses
135+
136+
```go
137+
func ExtractLicenses(expression string) ([]string, error)
138+
```
139+
140+
Function `ExtractLicenses` is used to extract licenses from the given expression without duplicates.
141+
142+
**parameter: expression**
143+
144+
`expression` is an SPDX expression string.
145+
146+
**returns**
147+
148+
Function `ExtractLicenses` has 2 return values. First is `[]string` which contains all of the SPDX licenses without duplicates.
149+
150+
The second return value is a `error` which is not `nil` if the given expression is not a valid SPDX expression.
151+
152+
#### Example
153+
154+
```go
155+
licenses, err := ExtractLicenses("(MIT AND APACHE-2.0) OR (APACHE-2.0)")
156+
assert.Equal(licenses, []string{"MIT", "Apache-2.0"})
157+
```
134158

135159
## Background
136160

0 commit comments

Comments
 (0)