Go, but with gadgets!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
503 B

package main
import (
"os"
"path/filepath"
"strings"
)
func listGadgets() []string {
set := make(map[string]struct{})
path := os.Getenv("PATH")
for _, dir := range filepath.SplitList(path) {
entries, err := os.ReadDir(dir)
if err != nil {
continue
}
for _, entry := range entries {
if !entry.IsDir() && strings.HasPrefix(entry.Name(), "go-") {
set[entry.Name()] = struct{}{}
}
}
}
s := make([]string, 0, len(set))
for k := range set {
s = append(s, k)
}
return s
}