From 1a0eb05bfaaaa3c4cc7c8a293cca6b17ee4d5ea3 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 30 Jan 2021 16:48:09 +0100 Subject: [PATCH] errcheck: Add more error checks --- cmd/restic/cmd_backup.go | 6 +++++- cmd/restic/cmd_forget.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index d8500b263..e769fef1f 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -119,7 +119,11 @@ func init() { f.StringVarP(&backupOptions.Host, "host", "H", "", "set the `hostname` for the snapshot manually. To prevent an expensive rescan use the \"parent\" flag") f.StringVar(&backupOptions.Host, "hostname", "", "set the `hostname` for the snapshot manually") - f.MarkDeprecated("hostname", "use --host") + err := f.MarkDeprecated("hostname", "use --host") + if err != nil { + // MarkDeprecated only returns an error when the flag could not be found + panic(err) + } f.StringArrayVar(&backupOptions.FilesFrom, "files-from", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)") f.StringArrayVar(&backupOptions.FilesFromVerbatim, "files-from-verbatim", nil, "read the files to backup from `file` (can be combined with file args; can be specified multiple times)") diff --git a/cmd/restic/cmd_forget.go b/cmd/restic/cmd_forget.go index ec90879ec..83b0ac91d 100644 --- a/cmd/restic/cmd_forget.go +++ b/cmd/restic/cmd_forget.go @@ -68,7 +68,11 @@ func init() { f.Var(&forgetOptions.KeepTags, "keep-tag", "keep snapshots with this `taglist` (can be specified multiple times)") f.StringArrayVar(&forgetOptions.Hosts, "host", nil, "only consider snapshots with the given `host` (can be specified multiple times)") f.StringArrayVar(&forgetOptions.Hosts, "hostname", nil, "only consider snapshots with the given `hostname` (can be specified multiple times)") - f.MarkDeprecated("hostname", "use --host") + err := f.MarkDeprecated("hostname", "use --host") + if err != nil { + // MarkDeprecated only returns an error when the flag is not found + panic(err) + } f.Var(&forgetOptions.Tags, "tag", "only consider snapshots which include this `taglist` in the format `tag[,tag,...]` (can be specified multiple times)")