From d909359b6d02de81ca0b4ee517828343d225e70d Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Wed, 29 Mar 2023 15:00:11 +0200 Subject: [PATCH] feat(license) read content from custom license file --- main.go | 10 +++++----- src/config/config.go | 3 --- src/utils/file.go | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 16d4837..7342358 100644 --- a/main.go +++ b/main.go @@ -25,11 +25,9 @@ func main() { utils.HandleError(err) contextPath, err := os.Getwd() utils.HandleError(err) - println(contextPath) - for _, license := range licenses { - println("Path in main.go:", license.Path) - } + contextPath += "/" + arg.ConfigPath config.AddLicensesToMap(licenses, contextPath) + println("") } arg.HandleArgs() @@ -46,7 +44,9 @@ func findLicense(license args.License) string { utils.HandleError(err) return string(content) } - return "" + b, err := os.ReadFile(license.File) + utils.HandleError(err) + return string(b) } func parseLicense(arg *args.Arguments, license string) string { diff --git a/src/config/config.go b/src/config/config.go index 02f5ccd..2e55bba 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -68,14 +68,11 @@ func GetLicenseConfigs(path string) ([]LicenseConfig, error) { } func (license *LicenseConfig) AddToMap(contextPath string) { - println("Path:", license.Path) args.AddLicense(license.ToLicense(contextPath), license.Identifier) } func AddLicensesToMap(licenses []LicenseConfig, contextPath string) { - println("F:", licenses[0].Path) for _, license := range licenses { - println("P:", license.Path) license.AddToMap(contextPath) } } diff --git a/src/utils/file.go b/src/utils/file.go index cd79ba9..128211e 100644 --- a/src/utils/file.go +++ b/src/utils/file.go @@ -22,7 +22,6 @@ func DecodeToml(content []byte, t any) { // // contextPath: the contextual path, with a slash (/) at the end func RelativeToAbsolute(path string, contextPath string) string { - println(path, contextPath) switch string(path[0]) { case "/": return path