From 9374645834ca2cb97e85bdbc7af8d9d5dd9fca1e Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Thu, 1 Dec 2022 11:08:47 -0500 Subject: [PATCH] rename package from expression to spdxexp Thoughts on the renaming: - expression is long for a go package name - exp is not specific (e.g. exp.Satisfies) - spdxexp hits the balance between short length and enough info to quickly distinguish it from other packages (e.g. spdxexp.Satisfies) --- README.md | 12 ++++++++++++ expression/doc.go | 7 ------- {expression => spdxexp}/compare.go | 2 +- {expression => spdxexp}/compare_test.go | 2 +- spdxexp/doc.go | 7 +++++++ {expression => spdxexp}/license.go | 2 +- {expression => spdxexp}/license_test.go | 2 +- {expression => spdxexp}/node.go | 4 ++-- {expression => spdxexp}/node_test.go | 2 +- {expression => spdxexp}/parse.go | 2 +- {expression => spdxexp}/parse_test.go | 2 +- {expression => spdxexp}/satisfies.go | 2 +- {expression => spdxexp}/satisfies_test.go | 2 +- {expression => spdxexp}/scan.go | 2 +- {expression => spdxexp}/scan_test.go | 2 +- {expression => spdxexp}/test_helper.go | 2 +- 16 files changed, 33 insertions(+), 21 deletions(-) delete mode 100644 expression/doc.go rename {expression => spdxexp}/compare.go (98%) rename {expression => spdxexp}/compare_test.go (99%) create mode 100644 spdxexp/doc.go rename {expression => spdxexp}/license.go (99%) rename {expression => spdxexp}/license_test.go (99%) rename {expression => spdxexp}/node.go (98%) rename {expression => spdxexp}/node_test.go (99%) rename {expression => spdxexp}/parse.go (99%) rename {expression => spdxexp}/parse_test.go (99%) rename {expression => spdxexp}/satisfies.go (99%) rename {expression => spdxexp}/satisfies_test.go (99%) rename {expression => spdxexp}/scan.go (99%) rename {expression => spdxexp}/scan_test.go (99%) rename {expression => spdxexp}/test_helper.go (97%) diff --git a/README.md b/README.md index 2a1adcd..3027123 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,18 @@ Golang implementation of a checker for determining if a set of SPDX IDs satisfies an SPDX Expression. +## Installation + +There are several ways to include a go package. To download and install, you can use `go get`. The command for that is: + +```sh +go get github.com/github/go-spdx@latest +``` + +## Packages + +- [spdxexp](https://pkg.go.dev/github.com/github/go-spdx/spdxexp) - Expression package validates licenses and determines if a license expression is satisfied by a list of licenses. Validity of a license is determined by the SPDX license list. + ## Public API _NOTE: The public API is initially limited to the Satisfies and ValidateLicenses functions. If diff --git a/expression/doc.go b/expression/doc.go deleted file mode 100644 index 0b23cb5..0000000 --- a/expression/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -Expression package validates licenses and determines if a license expression is satisfied by a list of licenses. -Validity of a license is determined by the [SPDX license list]. - -[SPDX license list]: https://spdx.org/licenses/ -*/ -package expression diff --git a/expression/compare.go b/spdxexp/compare.go similarity index 98% rename from expression/compare.go rename to spdxexp/compare.go index b6605ab..3c77a53 100644 --- a/expression/compare.go +++ b/spdxexp/compare.go @@ -1,4 +1,4 @@ -package expression +package spdxexp func compareGT(first *node, second *node) bool { if !first.isLicense() || !second.isLicense() { diff --git a/expression/compare_test.go b/spdxexp/compare_test.go similarity index 99% rename from expression/compare_test.go rename to spdxexp/compare_test.go index 3518ae5..16f00d1 100644 --- a/expression/compare_test.go +++ b/spdxexp/compare_test.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "testing" diff --git a/spdxexp/doc.go b/spdxexp/doc.go new file mode 100644 index 0000000..f487539 --- /dev/null +++ b/spdxexp/doc.go @@ -0,0 +1,7 @@ +/* +Spdxexp package validates licenses and determines if a license expression is satisfied by a list of licenses. +Validity of a license is determined by the [SPDX license list]. + +[SPDX license list]: https://spdx.org/licenses/ +*/ +package spdxexp diff --git a/expression/license.go b/spdxexp/license.go similarity index 99% rename from expression/license.go rename to spdxexp/license.go index 81dcbc1..6c521ab 100644 --- a/expression/license.go +++ b/spdxexp/license.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "strings" diff --git a/expression/license_test.go b/spdxexp/license_test.go similarity index 99% rename from expression/license_test.go rename to spdxexp/license_test.go index ceebee5..636c48e 100644 --- a/expression/license_test.go +++ b/spdxexp/license_test.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "testing" diff --git a/expression/node.go b/spdxexp/node.go similarity index 98% rename from expression/node.go rename to spdxexp/node.go index 51a89f3..392e95a 100644 --- a/expression/node.go +++ b/spdxexp/node.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "sort" @@ -167,7 +167,7 @@ func (n *node) reconstructedLicenseString() *string { return nil } -// Sort an array of license and license reference nodes alphebetically based +// Sort an array of license and license reference nodes alphabetically based // on their reconstructedLicenseString() representation. The sort function does not expect // expression nodes, but if one is in the nodes list, it will sort to the end. func sortLicenses(nodes []*node) { diff --git a/expression/node_test.go b/spdxexp/node_test.go similarity index 99% rename from expression/node_test.go rename to spdxexp/node_test.go index 0772494..4cabd47 100644 --- a/expression/node_test.go +++ b/spdxexp/node_test.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "testing" diff --git a/expression/parse.go b/spdxexp/parse.go similarity index 99% rename from expression/parse.go rename to spdxexp/parse.go index 28fcd0f..f1ce306 100644 --- a/expression/parse.go +++ b/spdxexp/parse.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "errors" diff --git a/expression/parse_test.go b/spdxexp/parse_test.go similarity index 99% rename from expression/parse_test.go rename to spdxexp/parse_test.go index c7b5497..15cdb2a 100644 --- a/expression/parse_test.go +++ b/spdxexp/parse_test.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "errors" diff --git a/expression/satisfies.go b/spdxexp/satisfies.go similarity index 99% rename from expression/satisfies.go rename to spdxexp/satisfies.go index dac0a82..abd4778 100644 --- a/expression/satisfies.go +++ b/spdxexp/satisfies.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "errors" diff --git a/expression/satisfies_test.go b/spdxexp/satisfies_test.go similarity index 99% rename from expression/satisfies_test.go rename to spdxexp/satisfies_test.go index 6dbf324..a676d24 100644 --- a/expression/satisfies_test.go +++ b/spdxexp/satisfies_test.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "errors" diff --git a/expression/scan.go b/spdxexp/scan.go similarity index 99% rename from expression/scan.go rename to spdxexp/scan.go index 0cb53ea..0af567c 100644 --- a/expression/scan.go +++ b/spdxexp/scan.go @@ -1,4 +1,4 @@ -package expression +package spdxexp /* Translation to Go from javascript code: https://github.com/clearlydefined/spdx-expression-parse.js/blob/master/scan.js */ diff --git a/expression/scan_test.go b/spdxexp/scan_test.go similarity index 99% rename from expression/scan_test.go rename to spdxexp/scan_test.go index 8404488..266ec62 100644 --- a/expression/scan_test.go +++ b/spdxexp/scan_test.go @@ -1,4 +1,4 @@ -package expression +package spdxexp import ( "errors" diff --git a/expression/test_helper.go b/spdxexp/test_helper.go similarity index 97% rename from expression/test_helper.go rename to spdxexp/test_helper.go index 2a3cd74..ce439e2 100644 --- a/expression/test_helper.go +++ b/spdxexp/test_helper.go @@ -1,4 +1,4 @@ -package expression +package spdxexp // getLicenseNode is a test helper method that is expected to create a valid // license node. Use this function when the test data is known to be a valid