Skip to content

Commit a7bf7da

Browse files
committed
Added 'remove' command
1 parent e27ba1a commit a7bf7da

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

apt.go

+13
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,16 @@ func UpgradeAll() (output []byte, err error) {
111111
cmd := exec.Command("apt-get", "upgrade", "-y")
112112
return cmd.CombinedOutput()
113113
}
114+
115+
// Remove removes a set of packages
116+
func Remove(packs ...*Package) (output []byte, err error) {
117+
args := []string{"remove", "-y"}
118+
for _, pack := range packs {
119+
if pack == nil || pack.Name == "" {
120+
return nil, fmt.Errorf("apt.Remove: Invalid package with empty Name")
121+
}
122+
args = append(args, pack.Name)
123+
}
124+
cmd := exec.Command("apt-get", args...)
125+
return cmd.CombinedOutput()
126+
}

0 commit comments

Comments
 (0)