go: implement improvements from rust #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "go/**" | |
- ".github/workflows/go.yml" | |
pull_request: | |
paths: | |
- "go/**" | |
- ".github/workflows/go.yml" | |
# Cancel previous runs for PRs but not pushes to main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "^1.21.6" | |
check-latest: true | |
- name: "Check go version" | |
run: go version | |
- name: Build | |
working-directory: go | |
run: chmod +x build.sh && ./build.sh | |
shell: bash | |
- name: Format | |
working-directory: ./go | |
run: | | |
if [ -n "$(gofmt -l .)" ]; then | |
echo "Code is not formatted with gofmt. Please format your code." | |
gofmt -d . | |
exit 1 | |
fi | |
shell: bash |