Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.

Commit 1b5da7e

Browse files
committed
chore: release v2.1.9
godoc-lint and golangci-lint now parse go.work `use (...)` when present, so test_apps/ or other out-of-workspace go.mod files no longer surface as typecheck errors.
1 parent 99667a8 commit 1b5da7e

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.1.9] - 2026-06-07
11+
12+
### Fixed
13+
14+
- `godoc-lint` / `golangci-lint`: honour `go.work` when present. Previously both hooks discovered `go.mod` files via `find` and lint each one, which caused `[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work` whenever a repository had a `go.work` but some `go.mod` files sat outside the workspace (e.g. `test_apps/go/`). The hooks now parse the `use (...)` list from `go.work` and lint only the included modules. Falls back to the existing `find`-based discovery when no `go.work` exists.
15+
1016
## [2.1.8] - 2026-06-07
1117

1218
### Fixed

hooks/godoc-lint/run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1010
REVIVE_CONFIG="${HOOK_DIR}/revive.toml"
1111

1212
# Discover Go module roots (mirrors hooks/golangci-lint/run.sh logic).
13+
# When a `go.work` file exists, honour the `use (...)` list so we don't lint
14+
# stale `go.mod` files that aren't part of the active workspace — golangci-lint
15+
# treats a `go.work`-mismatch as a typecheck error and exits non-zero even
16+
# when no linter found a real issue.
1317
mod_dirs=()
1418
if [[ -n "${KREUZBERG_GO_MOD_DIRS:-}" ]]; then
1519
IFS=':' read -ra mod_dirs <<<"${KREUZBERG_GO_MOD_DIRS}"
20+
elif [[ -f go.work ]]; then
21+
while IFS= read -r dir; do
22+
[[ -n "${dir}" && -f "${dir}/go.mod" ]] && mod_dirs+=("${dir}")
23+
done < <(awk '
24+
/^use[[:space:]]*\(/ { in_block=1; next }
25+
in_block && /^\)/ { in_block=0; next }
26+
in_block { gsub(/[[:space:]]+/, " "); for (i=1; i<=NF; i++) print $i }
27+
/^use[[:space:]]+[^(]/ { print $2 }
28+
' go.work)
1629
elif [[ -f go.mod ]]; then
1730
mod_dirs=(.)
1831
else

hooks/golangci-lint/run.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,21 @@ extract_archive_atomic "${archive_path}" "${extract_dir}" "${bin_path}" -xz
4949

5050
# Discover Go module roots so polyrepos / workspaces with several go.mod files
5151
# work without a top-level go.work. Honor KREUZBERG_GO_MOD_DIRS as a
52-
# colon-separated override list (paths relative to PWD).
52+
# colon-separated override list (paths relative to PWD). When a `go.work`
53+
# file exists, honour the `use (...)` list so stale go.mod files outside the
54+
# workspace don't surface as typecheck errors.
5355
mod_dirs=()
5456
if [[ -n "${KREUZBERG_GO_MOD_DIRS:-}" ]]; then
5557
IFS=':' read -ra mod_dirs <<<"${KREUZBERG_GO_MOD_DIRS}"
58+
elif [[ -f go.work ]]; then
59+
while IFS= read -r dir; do
60+
[[ -n "${dir}" && -f "${dir}/go.mod" ]] && mod_dirs+=("${dir}")
61+
done < <(awk '
62+
/^use[[:space:]]*\(/ { in_block=1; next }
63+
in_block && /^\)/ { in_block=0; next }
64+
in_block { gsub(/[[:space:]]+/, " "); for (i=1; i<=NF; i++) print $i }
65+
/^use[[:space:]]+[^(]/ { print $2 }
66+
' go.work)
5667
elif [[ -f go.mod ]]; then
5768
mod_dirs=(.)
5869
else

0 commit comments

Comments
 (0)