From 50843ab5f79a383a21fbe265d1cdef676ec9d6a7 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Thu, 14 Dec 2023 17:50:43 -0800 Subject: [PATCH 1/2] Fix check_gofmt --- Makefile | 1 - example/generated_examples_test.go | 2 +- scripts/check_gofmt.sh | 19 ++++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index cb4d1e837f..087be64d8f 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ check-api-clients: check-gofmt: scripts/check_gofmt.sh - lint: staticcheck diff --git a/example/generated_examples_test.go b/example/generated_examples_test.go index d26df0e6d3..e2e97c2ace 100644 --- a/example/generated_examples_test.go +++ b/example/generated_examples_test.go @@ -39,7 +39,7 @@ import ( issuing_authorization "github.com/stripe/stripe-go/v76/issuing/authorization" issuing_card "github.com/stripe/stripe-go/v76/issuing/card" issuing_cardholder "github.com/stripe/stripe-go/v76/issuing/cardholder" - issuing_dispute "github.com/stripe/stripe-go/v76/issuing/dispute" + issuing_dispute "github.com/stripe/stripe-go/v76/issuing/dispute" issuing_transaction "github.com/stripe/stripe-go/v76/issuing/transaction" loginlink "github.com/stripe/stripe-go/v76/loginlink" mandate "github.com/stripe/stripe-go/v76/mandate" diff --git a/scripts/check_gofmt.sh b/scripts/check_gofmt.sh index 4113d65fac..44bcc1e9f8 100755 --- a/scripts/check_gofmt.sh +++ b/scripts/check_gofmt.sh @@ -1,16 +1,17 @@ #!/bin/bash -find_files() { - find . -not \( \ - \( \ - -name 'vendor' \ - \) -prune \ - \) -name '*.go' -} +# go fmt supports ./... but gofmt does not. +# but go fmt always runs gofmt with -w, which replaces +# which we don't desire +# hence the need for this annoying script + -bad_files=$(find_files | xargs gofmt -s -l) +# go fmt -n prints the command that *would* +# be run by go fmt ./... +# so we just mangle that a bit +bad_files=$(gofmt -l $(go fmt -n ./... | cut -d ' ' -f4-)) if [[ -n "${bad_files}" ]]; then - echo "!!! gofmt -s needs to be run on the following files: " + echo "!!! gofmt -w needs to be run on the following files: " echo "${bad_files}" exit 1 fi From b6a59bf0ce449e97df09e648eefbbc891f3ea8f4 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Thu, 14 Dec 2023 18:12:07 -0800 Subject: [PATCH 2/2] Fix --- example/generated_examples_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/generated_examples_test.go b/example/generated_examples_test.go index e2e97c2ace..d26df0e6d3 100644 --- a/example/generated_examples_test.go +++ b/example/generated_examples_test.go @@ -39,7 +39,7 @@ import ( issuing_authorization "github.com/stripe/stripe-go/v76/issuing/authorization" issuing_card "github.com/stripe/stripe-go/v76/issuing/card" issuing_cardholder "github.com/stripe/stripe-go/v76/issuing/cardholder" - issuing_dispute "github.com/stripe/stripe-go/v76/issuing/dispute" + issuing_dispute "github.com/stripe/stripe-go/v76/issuing/dispute" issuing_transaction "github.com/stripe/stripe-go/v76/issuing/transaction" loginlink "github.com/stripe/stripe-go/v76/loginlink" mandate "github.com/stripe/stripe-go/v76/mandate"