From baa4dc16ea37a3832716526f5080454cee232bfe Mon Sep 17 00:00:00 2001 From: Jim Male <2423859+jimmale@users.noreply.github.com> Date: Wed, 15 Dec 2021 15:31:46 -0600 Subject: [PATCH] fix: swapped code around to make go-licenses work better with the embed package See discussion at https://github.com/google/go-licenses/pull/79 --- save.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/save.go b/save.go index e01f9b2..12c1f3e 100644 --- a/save.go +++ b/save.go @@ -61,6 +61,17 @@ func init() { } func saveMain(_ *cobra.Command, args []string) error { + + classifier, err := licenses.NewClassifier(confidenceThreshold) + if err != nil { + return err + } + + libs, err := licenses.Libraries(context.Background(), classifier, args...) + if err != nil { + return err + } + if overwriteSavePath { if err := os.RemoveAll(savePath); err != nil { return err @@ -76,15 +87,6 @@ func saveMain(_ *cobra.Command, args []string) error { return err } - classifier, err := licenses.NewClassifier(confidenceThreshold) - if err != nil { - return err - } - - libs, err := licenses.Libraries(context.Background(), classifier, args...) - if err != nil { - return err - } libsWithBadLicenses := make(map[licenses.Type][]*licenses.Library) for _, lib := range libs { libSaveDir := filepath.Join(savePath, unvendor(lib.Name()))