Skip to content

Merge pull request #9 from yeeaiclub/dependabot/github_actions/action… #34

Merge pull request #9 from yeeaiclub/dependabot/github_actions/action…

Merge pull request #9 from yeeaiclub/dependabot/github_actions/action… #34

Workflow file for this run

# Copyright 2025 yeeaiclub
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Format Go Code
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
check-go-fmt:
name: Check Go Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0 # Full clone to support git diff checks
- name: Set up Go
uses: actions/setup-go@v6.4.0
with:
go-version: "1.24.2"
- name: Install goimports
run: |
go install golang.org/x/tools/cmd/goimports@v0.33.0
- name: Run goimports and check diffs
id: fmt-check
run: |
find . -name "*.go" ! -path "./vendor/*" -exec goimports -w {} +
if git diff --quiet; then
echo "✅ All Go files are correctly formatted."
else
echo "❌ Some Go files are not formatted. Please run 'goimports -w .' and commit the changes."
git diff
exit 1
fi
- name: Notify on formatting issues
if: failure()
run: |
echo "⚠️ The submitted code contains unformatted Go files. Please fix them before submitting."