summaryrefslogtreecommitdiff
path: root/dpkgQuery.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-15 09:50:13 -0600
committerJeff Carr <[email protected]>2024-11-15 09:50:13 -0600
commitea96d4880eedd92d9c8228b84de028185ec941b2 (patch)
tree8c8f317c1ddca756e7c1bc12c132855e6d32833c /dpkgQuery.go
parent7b069233955c6f35270f0cb2cb49bf6038c11020 (diff)
does apt_linux.go vs apt_windows.go work automagically?
Diffstat (limited to 'dpkgQuery.go')
-rw-r--r--dpkgQuery.go41
1 files changed, 0 insertions, 41 deletions
diff --git a/dpkgQuery.go b/dpkgQuery.go
deleted file mode 100644
index 7369d62..0000000
--- a/dpkgQuery.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package main
-
-import (
- "bufio"
- "os/exec"
- "strings"
-)
-
-func getInstalledPackages() (map[string]string, error) {
- // Run the dpkg-query command to list installed packages and versions
- cmd := exec.Command("dpkg-query", "-W", "-f=${Package} ${Version}\n")
- stdout, err := cmd.StdoutPipe()
- if err != nil {
- return nil, err
- }
-
- // Start the command execution
- if err := cmd.Start(); err != nil {
- return nil, err
- }
- defer cmd.Wait()
-
- // Create a map to store package names and versions
- installedPackages := make(map[string]string)
-
- // Use a scanner to read the output of the command line by line
- scanner := bufio.NewScanner(stdout)
- for scanner.Scan() {
- line := scanner.Text()
- // Split each line into package name and version
- parts := strings.SplitN(line, " ", 2)
- if len(parts) == 2 {
- packageName := parts[0]
- version := parts[1]
- installedPackages[packageName] = version
- }
- }
-
- // Return the map with package names and versions
- return installedPackages, scanner.Err()
-}