structlint is designed to work seamlessly in CI/CD pipelines.
name: Validate Structure
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Install structlint
run: go install github.com/AxeForging/structlint@latest
- name: Validate structure
run: structlint validate --config .structlint.yaml - name: Validate structure
run: structlint validate --json-output report.json
- name: Upload report
uses: actions/upload-artifact@v4
if: always()
with:
name: structlint-report
path: report.jsonstructlint:
image: golang:1.24
stage: test
script:
- go install github.com/AxeForging/structlint@latest
- structlint validate --config .structlint.yaml
artifacts:
when: always
paths:
- report.json
expire_in: 1 weekpipeline {
agent any
stages {
stage('Validate Structure') {
steps {
sh 'go install github.com/AxeForging/structlint@latest'
sh 'structlint validate --json-output report.json'
}
post {
always {
archiveArtifacts artifacts: 'report.json'
}
}
}
}
}Add to .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: structlint
name: structlint
entry: structlint validate
language: system
pass_filenames: false
always_run: trueOr with lefthook (.lefthook.yml):
pre-commit:
commands:
structlint:
run: structlint validate --silentFROM golang:1.24-alpine AS builder
RUN go install github.com/AxeForging/structlint@latest
FROM alpine:latest
COPY --from=builder /go/bin/structlint /usr/local/bin/
ENTRYPOINT ["structlint"]Usage:
docker run --rm -v $(pwd):/project -w /project structlint validate.PHONY: lint-structure
lint-structure:
@structlint validate --config .structlint.yaml
ci: lint test lint-structure build-
Run early in the pipeline - Structure validation is fast and catches issues before expensive builds
-
Use strict mode in CI - Add
--strictflag to fail on warnings -
Generate reports - Always generate JSON reports for debugging
-
Cache the binary - In GitHub Actions, Go install is cached automatically with
actions/setup-go -
Fail fast - Put structlint before tests to catch structure issues immediately