Skip to content

Commit 4d0de03

Browse files
committed
Fix lint.
1 parent 5685f79 commit 4d0de03

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

list_unix.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
package zenity
44

5-
import "github.com/ncruces/zenity/internal/zenutil"
5+
import (
6+
"slices"
7+
8+
"github.com/ncruces/zenity/internal/zenutil"
9+
)
610

711
func list(text string, items []string, opts options) (string, error) {
812
args := []string{"--list", "--hide-header", "--text", text}
@@ -27,15 +31,6 @@ func list(text string, items []string, opts options) (string, error) {
2731
return strResult(opts, out, err)
2832
}
2933

30-
func isSelected(defaults []string, value string) string {
31-
for _, d := range defaults {
32-
if d == value {
33-
return "TRUE"
34-
}
35-
}
36-
return "FALSE"
37-
}
38-
3934
func listMultiple(text string, items []string, opts options) ([]string, error) {
4035
args := []string{"--list", "--hide-header", "--text", text, "--multiple", "--separator", zenutil.Separator}
4136
args = appendGeneral(args, opts)
@@ -48,7 +43,11 @@ func listMultiple(text string, items []string, opts options) ([]string, error) {
4843
if opts.listKind == checkListKind || len(opts.defaultItems) > 0 {
4944
args = append(args, "--checklist", "--column=", "--column=")
5045
for _, i := range items {
51-
args = append(args, isSelected(opts.defaultItems, i), i)
46+
selected := ""
47+
if slices.Contains(opts.defaultItems, i) {
48+
selected = "true"
49+
}
50+
args = append(args, selected, i)
5251
}
5352
} else {
5453
args = append(args, "--column=")

0 commit comments

Comments
 (0)