Enable errcheck linter and resolve found issues.

Signed-off-by: Xun Jiang <blackpiglet@gmail.com>
This commit is contained in:
Xun Jiang
2023-04-28 09:33:42 +08:00
parent fbba4e5c77
commit f051ecaee9
19 changed files with 124 additions and 41 deletions
+16 -4
View File
@@ -64,7 +64,10 @@ $ velero completion fish > ~/.config/fish/completions/velero.fish
shell := args[0]
switch shell {
case "bash":
cmd.Root().GenBashCompletion(os.Stdout)
if err := cmd.Root().GenBashCompletion(os.Stdout); err != nil {
fmt.Println("fail to generate bash completion script", err)
os.Exit(1)
}
case "zsh":
// # fix #4912
// cobra does not support zsh completion ouptput used by source command
@@ -72,11 +75,20 @@ $ velero completion fish > ~/.config/fish/completions/velero.fish
// Need to append compdef manually to do that.
zshHead := "#compdef velero\ncompdef _velero velero\n"
out := os.Stdout
out.Write([]byte(zshHead))
if _, err := out.Write([]byte(zshHead)); err != nil {
fmt.Println("fail to append compdef command into zsh completion script: ", err)
os.Exit(1)
}
cmd.Root().GenZshCompletion(out)
if err := cmd.Root().GenZshCompletion(out); err != nil {
fmt.Println("fail to generate zsh completion script: ", err)
os.Exit(1)
}
case "fish":
cmd.Root().GenFishCompletion(os.Stdout, true)
if err := cmd.Root().GenFishCompletion(os.Stdout, true); err != nil {
fmt.Println("fail to generate fish completion script: ", err)
os.Exit(1)
}
default:
fmt.Println("Invalid shell specified, specify bash, zsh, or fish")
os.Exit(1)