Skip to content

Workflow

Workflow #14

Workflow file for this run

name: Check Go Format
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
go-fmt-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: List files in the repository
run: ls -R
- name: Find Go files
run: find . -name "*.go"
- name: Run gofmt
run: |
GOFMT_OUTPUT=$(gofmt -l .)
if [ -n "$GOFMT_OUTPUT" ]; then
echo "以下Go文件格式不正确:"
echo "$GOFMT_OUTPUT"
exit 1
else
echo "所有Go文件格式正确。"
fi