From 7d69049e9306b10500b9122613b02159bf4fb51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D7=A0=CF=85=CE=B1=CE=B7=20=D7=A0=CF=85=CE=B1=CE=B7=D1=95?= =?UTF-8?q?=CF=83=CE=B7?= Date: Thu, 9 Apr 2026 22:41:46 -0700 Subject: [PATCH] feat(go): exclude node_modules from fmt and add overrides MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add ! -path '*/node_modules/*' to all find commands in fmt and fmt-check recipes. npm packages like flatted ship .go files that break formatting checks in monorepos with ui/ directories. Add JUST_GO_FMT_EXCLUDES env var so consuming projects can pass extra find exclusions without forking the shared justfile. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- README.md | 2 ++ go.just | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3be6ea0..a8141fe 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,8 @@ test: go::test go::docs-check bats::test - `JUST_MAIN_PACKAGE` - main package path (default: `main.go`) - `JUST_COVERAGE_DIR` - coverage output directory (default: `.coverage`) +- `JUST_GO_FMT_EXCLUDES` - extra `find` exclusions for `fmt` / `fmt-check` + (e.g., `! -path '*/vendor/*'`) - `JUST_DOCS_DIR` - generated docs output directory (default: `docs/gen`) ### bats.just diff --git a/go.just b/go.just index f734af1..b57f51d 100644 --- a/go.just +++ b/go.just @@ -27,6 +27,7 @@ git_root := `git rev-parse --show-toplevel` main_package := env("JUST_MAIN_PACKAGE", "main.go") coverage_dir := env("JUST_COVERAGE_DIR", ".coverage") +go_fmt_excludes := env("JUST_GO_FMT_EXCLUDES", "") os_tags := if os() == "linux" { `if grep -iq 'ubuntu' /etc/os-release 2>/dev/null; then echo '-tags=ubuntu'; fi` } else { "" } # --- Private dependency recipes --- @@ -120,14 +121,14 @@ test: mod fmt-check vet unit-cov # Reformat Go files with gofumpt + golines [group('fmt')] fmt: _fmt-deps - find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' | xargs go tool mvdan.cc/gofumpt -l -w - find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' | xargs go tool github.com/segmentio/golines --base-formatter="go tool mvdan.cc/gofumpt" -w + find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' ! -path '*/node_modules/*' {{ go_fmt_excludes }} | xargs go tool mvdan.cc/gofumpt -l -w + find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' ! -path '*/node_modules/*' {{ go_fmt_excludes }} | xargs go tool github.com/segmentio/golines --base-formatter="go tool mvdan.cc/gofumpt" -w # Check Go file formatting [group('fmt')] fmt-check: _fmt-deps - test -z "$(find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' | xargs go tool mvdan.cc/gofumpt -d -e | tee /dev/stderr)" - test -z "$(find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' | xargs go tool github.com/segmentio/golines --dry-run --base-formatter="go tool mvdan.cc/gofumpt" -l | tee /dev/stderr)" + test -z "$(find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' ! -path '*/node_modules/*' {{ go_fmt_excludes }} | xargs go tool mvdan.cc/gofumpt -d -e | tee /dev/stderr)" + test -z "$(find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' ! -path './.worktrees/*' ! -path './.claude/*' ! -path '*/node_modules/*' {{ go_fmt_excludes }} | xargs go tool github.com/segmentio/golines --dry-run --base-formatter="go tool mvdan.cc/gofumpt" -l | tee /dev/stderr)" # --- Codegen ---