Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gofmt to format and lint #1788

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ check-api-clients:
go run scripts/check_api_clients/main.go

check-gofmt:
scripts/check_gofmt.sh
scripts/gofmt.sh check

lint:
staticcheck
Expand Down Expand Up @@ -39,7 +39,7 @@ update-version:
$(MAKE) normalize-imports

codegen-format: normalize-imports
go fmt ./...
scripts/gofmt.sh
go install golang.org/x/tools/cmd/goimports@latest && goimports -w example/generated_examples_test.go

CURRENT_MAJOR_VERSION := $(shell cat VERSION | sed 's/\..*//')
Expand Down
16 changes: 0 additions & 16 deletions scripts/check_gofmt.sh

This file was deleted.

20 changes: 20 additions & 0 deletions scripts/gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

find_files() {
find . -name '*.go' -not -path "./vendor/*" -not -path "./.git/*"
}

bad_files=$(find_files | xargs gofmt -s -l)

if [[ "$1" == "check" ]]; then
if [[ -n "${bad_files}" ]]; then
echo "!!! gofmt -s needs to be run on the following files: "
echo "${bad_files}"
exit 1
fi
fi

for file in ${bad_files}; do
gofmt -s -w "${file}"
done
exit 0
Loading