File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,30 @@ assert.True(valid)
131131assert.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
You can’t perform that action at this time.
0 commit comments