From 26cca4813a939db099a02e668c68b866d3e06f5b Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 8 Jun 2024 18:47:07 -0700 Subject: [PATCH] Bump golangci-lint and fix lint --- .github/workflows/main.yml | 2 +- Makefile | 2 +- main.go | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91af259a0..1d7ed7769 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: working-directory: git-sync - version: v1.53.3 + version: v1.59.0 - name: make lint working-directory: git-sync diff --git a/Makefile b/Makefile index 1b3c22e08..eee2cf33b 100644 --- a/Makefile +++ b/Makefile @@ -281,6 +281,6 @@ lint-staticcheck: go run honnef.co/go/tools/cmd/staticcheck@2023.1.3 lint-golangci-lint: - go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3 run + go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0 run lint: lint-staticcheck lint-golangci-lint diff --git a/main.go b/main.go index f2dfa58dd..e79c02819 100644 --- a/main.go +++ b/main.go @@ -142,7 +142,7 @@ func main() { flVersion := pflag.Bool("version", false, "print the version and exit") flHelp := pflag.BoolP("help", "h", false, "print help text and exit") pflag.BoolVarP(flHelp, "__?", "?", false, "print help text and exit") // support -? as an alias to -h - pflag.CommandLine.MarkHidden("__?") + mustMarkHidden("__?") flManual := pflag.Bool("man", false, "print the full manual and exit") flVerbose := pflag.IntP("verbose", "v", @@ -923,6 +923,16 @@ func mustMarkDeprecated(name string, usageMessage string) { } } +// mustMarkHidden is a helper around pflag.CommandLine.MarkHidden. +// It panics if there is an error (as these indicate a coding issue). +// This makes it easier to keep the linters happy. +func mustMarkHidden(name string) { + err := pflag.CommandLine.MarkHidden(name) + if err != nil { + panic(fmt.Sprintf("error marking flag %q as hidden: %v", name, err)) + } +} + // makeAbsPath makes an absolute path from a path which might be absolute // or relative. If the path is already absolute, it will be used. If it is // not absolute, it will be joined with the provided root. If the path is