From e8d64e304cfa17c0cc804481472bc1b0c34256bd Mon Sep 17 00:00:00 2001 From: Dustin Davis <1dustindavis@gmail.com> Date: Mon, 17 May 2021 00:50:08 +0000 Subject: [PATCH 1/2] Add comment for exported Print function --- pkg/report/report.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/report/report.go b/pkg/report/report.go index 7557a06..96abc5b 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -86,11 +86,13 @@ func End() { } -func Print () { +// Print writes the report to stdout instead of writing to disk +// Used in check only mode +func Print() { // Compile everything Items["InstalledItems"] = InstalledItems Items["UninstalledItems"] = UninstalledItems - + reportJSON, marshalErr := json.MarshalIndent(Items, "", " ") fmt.Println(string(reportJSON)) if marshalErr != nil { From f78b945a210fa9200a98f93a70e99a77440b2991 Mon Sep 17 00:00:00 2001 From: Dustin Davis <1dustindavis@gmail.com> Date: Mon, 17 May 2021 01:00:16 +0000 Subject: [PATCH 2/2] Apply gofmt formatting recommendations --- pkg/catalog/catalog.go | 4 ++-- pkg/config/config.go | 24 ++++++++++++------------ pkg/config/config_test.go | 2 +- pkg/gorillalog/gorillalog.go | 6 +++--- pkg/status/registry.go | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pkg/catalog/catalog.go b/pkg/catalog/catalog.go index 5169233..2ca677f 100644 --- a/pkg/catalog/catalog.go +++ b/pkg/catalog/catalog.go @@ -19,8 +19,8 @@ type Item struct { Installer InstallerItem `yaml:"installer"` Uninstaller InstallerItem `yaml:"uninstaller"` Version string `yaml:"version"` - BlockingApps []string `yaml:"blocking_apps"` - PreScript string `yaml:"preinstall_script"` + BlockingApps []string `yaml:"blocking_apps"` + PreScript string `yaml:"preinstall_script"` PostScript string `yaml:"postinstall_script"` } diff --git a/pkg/config/config.go b/pkg/config/config.go index 49d2bfe..03cda08 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -18,20 +18,20 @@ var ( cachePath string // Define flag defaults - aboutArg bool - aboutDefault = false - configArg string - configDefault = filepath.Join(os.Getenv("ProgramData"), "gorilla/config.yaml") - debugArg bool - debugDefault = false - helpArg bool - helpDefault = false - verboseArg bool - verboseDefault = false + aboutArg bool + aboutDefault = false + configArg string + configDefault = filepath.Join(os.Getenv("ProgramData"), "gorilla/config.yaml") + debugArg bool + debugDefault = false + helpArg bool + helpDefault = false + verboseArg bool + verboseDefault = false checkOnlyArg bool checkOnlyDefault = false - versionArg bool - versionDefault = false + versionArg bool + versionDefault = false // Use a fake function so we can override when testing osExit = os.Exit diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index c03dea5..8872625 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -19,7 +19,7 @@ func TestGet(t *testing.T) { AppDataPath: filepath.Clean("c:/cpe/gorilla/"), Verbose: true, Debug: true, - CheckOnly: true, + CheckOnly: true, AuthUser: "johnny", AuthPass: "pizza", CachePath: filepath.Clean("c:/cpe/gorilla/cache"), diff --git a/pkg/gorillalog/gorillalog.go b/pkg/gorillalog/gorillalog.go index e6895d9..1a2185e 100644 --- a/pkg/gorillalog/gorillalog.go +++ b/pkg/gorillalog/gorillalog.go @@ -11,9 +11,9 @@ import ( var ( // Define these config variables at the package scope - debug bool - verbose bool - checkonly bool + debug bool + verbose bool + checkonly bool ) // TODO rewrite with io.multiwriter diff --git a/pkg/status/registry.go b/pkg/status/registry.go index 11cf991..06c87b4 100644 --- a/pkg/status/registry.go +++ b/pkg/status/registry.go @@ -34,10 +34,10 @@ func getUninstallKeys() (installedItems map[string]RegistryApplication, checkErr // Both Uninstall paths (64 & 32 bits apps) regPaths := []string{`Software\Microsoft\Windows\CurrentVersion\Uninstall`, - `Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall`} + `Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall`} for _, regPath := range regPaths { - + // Get the Uninstall key from HKLM key, checkErr := registry.OpenKey(registry.LOCAL_MACHINE, regPath, registry.READ) if checkErr != nil {