From 2b66775f45abf2f549a0668ea600cca1d47f0339 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 13 Dec 2022 16:19:46 +0530 Subject: [PATCH] explicitly ignore a few errors --- tools/cli/command.go | 4 ++-- tools/cli/completion-main.go | 5 ++++- tools/cli/files.go | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/cli/command.go b/tools/cli/command.go index f232307fa..75428383a 100644 --- a/tools/cli/command.go +++ b/tools/cli/command.go @@ -263,7 +263,7 @@ func (self *Command) VisitAllOptions(callback func(*Option) error) error { func (self *Command) AllOptions() []*Option { ans := make([]*Option, 0, 64) - self.VisitAllOptions(func(o *Option) error { ans = append(ans, o); return nil }) + _ = self.VisitAllOptions(func(o *Option) error { ans = append(ans, o); return nil }) return ans } @@ -331,7 +331,7 @@ func (self *Command) SuggestionsForCommand(name string, max_distance int /* good func (self *Command) SuggestionsForOption(name_with_hyphens string, max_distance int /* good default is 2 */) []string { ans := make([]string, 0, 8) q := strings.ToLower(name_with_hyphens) - self.VisitAllOptions(func(opt *Option) error { + _ = self.VisitAllOptions(func(opt *Option) error { for _, a := range opt.Aliases { as := a.String() if utils.LevenshteinDistance(as, q, true) <= max_distance { diff --git a/tools/cli/completion-main.go b/tools/cli/completion-main.go index d9d4de6fb..b7059a3a8 100644 --- a/tools/cli/completion-main.go +++ b/tools/cli/completion-main.go @@ -88,7 +88,10 @@ func GenerateCompletions(args []string) error { re(root) } - root.Validate() + err = root.Validate() + if err != nil { + return err + } all_completions := make([]*Completions, 0, 1) for _, argv := range all_argv { all_completions = append(all_completions, root.GetCompletions(argv, init_completions[output_type])) diff --git a/tools/cli/files.go b/tools/cli/files.go index d7a0ca063..eb3406a48 100644 --- a/tools/cli/files.go +++ b/tools/cli/files.go @@ -150,7 +150,7 @@ func is_dir_or_symlink_to_dir(entry os.DirEntry, path string) bool { func fname_based_completer(prefix, cwd string, is_match func(string) bool) []string { ans := make([]string, 0, 1024) - CompleteFiles(prefix, func(entry *FileEntry) { + _ = CompleteFiles(prefix, func(entry *FileEntry) { if entry.IsDir && !entry.IsEmptyDir { entries, err := os.ReadDir(entry.Abspath) if err == nil { @@ -287,7 +287,7 @@ func CompleteExecutableFirstArg(completions *Completions, word string, arg_num i mg := completions.AddMatchGroup("Executables") mg.IsFiles = true - CompleteFiles(word, func(entry *FileEntry) { + _ = CompleteFiles(word, func(entry *FileEntry) { if entry.IsDir && !entry.IsEmptyDir { // only allow directories that have sub-dirs or executable files in them entries, err := os.ReadDir(entry.Abspath) @@ -324,7 +324,7 @@ func DirectoryCompleter(title string, relative_to relative_to) CompletionFunc { mg := completions.AddMatchGroup(title) mg.NoTrailingSpace = true mg.IsFiles = true - CompleteFiles(word, func(entry *FileEntry) { + _ = CompleteFiles(word, func(entry *FileEntry) { if entry.Mode.IsDir() { mg.AddMatch(entry.CompletionCandidate) }