Skip to content

Commit

Permalink
docs: update docs to include extract licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhenry committed Sep 19, 2023
1 parent 7fe1a57 commit 4f63854
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,30 @@ assert.True(valid)
assert.NotContains(invalidLicenses, "MIT AND APACHE-2.0")
```

### ExtractLicenses

```go
func ExtractLicenses(expression string) ([]string, error)
```

Function `ExtractLicenses` is used to extract licenses from the given expression without duplicates.

**parameter: expression**

`expression` is an SPDX expression string.

**returns**

Function `ExtractLicenses` has 2 return values. First is `[]string` which contains all of the SPDX licenses without duplicates.

The second return value is a `error` which is not `nil` if the given expression is not a valid SPDX expression.

#### Example

```go
licenses, err := ExtractLicenses("(MIT AND APACHE-2.0) OR (APACHE-2.0)")
assert.Equal(licenses, []string{"MIT", "Apache-2.0"})
```

## Background

Expand Down

0 comments on commit 4f63854

Please sign in to comment.