Skip to content

Commit ca367db

Browse files
authored
Merge pull request #28 from DoDAON/feat/go-profile
feat: add Go profile with fixture and smoke test
2 parents 8f45609 + e720c35 commit ca367db

12 files changed

Lines changed: 164 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<img alt="FastAPI" src="https://img.shields.io/badge/FastAPI-009688?style=flat-square&logo=fastapi&logoColor=white" />
1818
<img alt="Spring Boot" src="https://img.shields.io/badge/Spring_Boot-6DB33F?style=flat-square&logo=springboot&logoColor=white" />
1919
<img alt="Android" src="https://img.shields.io/badge/Android-3DDC84?style=flat-square&logo=android&logoColor=white" />
20+
<img alt="Go" src="https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white" />
2021
<img alt="Contributors" src="https://img.shields.io/github/contributors/baskduf/harness-starter-kit?style=flat-square" />
2122
</p>
2223

docs/profiles.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Available profiles:
1818
- `android`
1919
- `react`
2020
- `vue`
21+
- `go`
2122

2223
## How Agents Use Profiles
2324

docs/validation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Automated fixture smoke tests cover harness installation for:
4444
- Spring Boot
4545
- Android / Kotlin Gradle
4646
- Vue
47+
- Go
4748

4849
These tests verify that the installer preserves existing files, writes expected
4950
profile snippets, and produces runnable generic drift checks.

scripts/apply_harness.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def parse_args() -> argparse.Namespace:
7171
"fastapi",
7272
"react",
7373
"vue",
74+
"go",
7475
),
7576
default="generic",
7677
help="Optional stack profile. Profiles add reference snippets only.",

scripts/check_docs_drift.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"out/",
5151
"target",
5252
"target/",
53+
"vendor",
54+
"vendor/",
5355
"target-repo/harness-starter-kit",
5456
"scripts/check_harness.py",
5557
"tsconfig.tsbuildinfo",

templates/generic/scripts/check_docs_drift.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"out/",
5151
"target",
5252
"target/",
53+
"vendor",
54+
"vendor/",
5355
"target-repo/harness-starter-kit",
5456
"scripts/check_harness.py",
5557
"tsconfig.tsbuildinfo",

templates/profiles/go/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Go Harness Profile
2+
3+
Use these snippets when the target project is a Go module or service.
4+
5+
These files are agent reference material, not automatic transformations. Merge
6+
only the pieces that fit the target project's existing tools.
7+
8+
Apply this profile by priority: always preserve the target module path, generated
9+
file boundaries, and exact local check commands; document database, auth, or
10+
external API setup when present; consider decision records only when changing
11+
module boundaries, persistence approach, auth flow, or external integration
12+
policy; use a short report/check note for narrow fixes.
13+
14+
## Recommended Checks
15+
16+
- `go build ./...` to verify the module compiles.
17+
- `go vet ./...` for static analysis included in the Go toolchain.
18+
- `golangci-lint run` when the target project has `.golangci.yml`,
19+
`.golangci.yaml`, or `.golangci.toml`. Do not add golangci-lint if it is absent.
20+
- `go test ./...` for unit tests. Add `-count=1` to disable test result caching
21+
when the results must reflect the current state.
22+
- `scripts/check_docs_drift.py` for stale documentation references.
23+
- `scripts/check_structure.py` for temporary or drift-prone files.
24+
25+
## Generated Files
26+
27+
Go projects often include code generated by tools such as `sqlc`, `protoc`,
28+
`mockgen`, `stringer`, `templ`, or similar. These files are source: do not
29+
edit them directly and do not omit them from version control unless the
30+
target project policy says otherwise. Record generated paths in `AGENTS.md`
31+
so agents know not to edit them.
32+
33+
If the target project has a code generation step, document the command in
34+
`AGENTS.md` so agents can regenerate when the schema or interface changes.
35+
36+
## Suggested Check Script
37+
38+
Copy or adapt `check_harness.py` into the target repository's `scripts/`
39+
directory when the project has no existing task runner. It runs `go vet`,
40+
`golangci-lint` when the target has a golangci-lint config, and the generic
41+
drift checks.
42+
43+
## Profile Absorption Notes
44+
45+
When Go is introduced after generic adoption:
46+
47+
- Merge relevant ignores from `gitignore.harness.txt`, especially build
48+
outputs, vendor directories, and the local `harness-starter-kit/` clone.
49+
- Copy or adapt `check_harness.py` into `scripts/` only when the target has no
50+
equivalent local verification command.
51+
- Update `AGENTS.md` with the module path, package layout conventions,
52+
generated file paths, and completion checks.
53+
- Update `docs/conventions/coding.md` with package boundaries, error handling,
54+
interface definition placement, testing approach, and any project-specific
55+
patterns agents should repeat.
56+
- Consider a decision record when changing or selecting the module structure,
57+
persistence layer, auth approach, external integration policy, or code
58+
generation tooling. When the task only follows the existing architecture or
59+
makes a narrow fix, a final report or check note is enough.
60+
- In the final report, list which snippets were adopted, adapted, skipped, or
61+
deferred.
62+
63+
## Go Notes
64+
65+
- Keep `go.mod` and `go.sum` as source. Do not edit `go.sum` manually.
66+
- Use `go mod tidy` after adding or removing dependencies.
67+
- Do not commit build output binaries or the local `harness-starter-kit/` clone.
68+
- Add `vendor/` to `.gitignore` unless the target project intentionally vendors
69+
dependencies.
70+
- Protect generated file directories in `AGENTS.md` so agents do not overwrite
71+
them by hand.
72+
- Prefer table-driven tests with `t.Run` for cases that share setup.
73+
- Add integration or end-to-end tests only when the target project already has
74+
a test database, container, or emulator setup in place.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python3
2+
"""Run local harness checks for a Go project."""
3+
4+
from __future__ import annotations
5+
6+
import argparse
7+
import shutil
8+
import subprocess
9+
import sys
10+
from pathlib import Path
11+
12+
13+
def repo_root() -> Path:
14+
current = Path(__file__).resolve()
15+
if current.parent.name == "scripts":
16+
return current.parents[1]
17+
18+
cwd = Path.cwd()
19+
if (cwd / "scripts" / "check_docs_drift.py").exists():
20+
return cwd
21+
22+
for candidate in (current.parent, *current.parents):
23+
if (candidate / "go.mod").exists():
24+
return candidate
25+
return cwd
26+
27+
28+
ROOT = repo_root()
29+
30+
31+
def run(command: list[str]) -> None:
32+
subprocess.run(command, cwd=ROOT, check=True)
33+
34+
35+
def main() -> int:
36+
parser = argparse.ArgumentParser(description="Run Go harness checks.")
37+
parser.add_argument(
38+
"--skip-tests",
39+
action="store_true",
40+
help="Run only vet and harness drift checks.",
41+
)
42+
args = parser.parse_args()
43+
44+
run(["go", "build", "./..."])
45+
run(["go", "vet", "./..."])
46+
47+
lint_configs = (".golangci.yml", ".golangci.yaml", ".golangci.toml")
48+
if shutil.which("golangci-lint") and any((ROOT / name).exists() for name in lint_configs):
49+
run(["golangci-lint", "run"])
50+
51+
if not args.skip_tests:
52+
run(["go", "test", "-count=1", "./..."])
53+
54+
run([sys.executable, "scripts/check_docs_drift.py"])
55+
run([sys.executable, "scripts/check_structure.py"])
56+
return 0
57+
58+
59+
if __name__ == "__main__":
60+
raise SystemExit(main())
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Go build outputs
2+
/bin/
3+
/dist/
4+
*.exe
5+
*.test
6+
*.out
7+
8+
# Dependency vendor directory (omit this line if the project vendors intentionally)
9+
vendor/
10+
11+
# Test cache
12+
/tmp/
13+
14+
# Harness kit reference clone
15+
harness-starter-kit/

tests/fixtures/go-basic/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Go Basic Fixture
2+
3+
A minimal Go module shape used to smoke-test harness adoption.

0 commit comments

Comments
 (0)