Small helper script to compare student code.go with the solution complete.go for exercises.
From repository root:
./course-helper --module 3 --lesson 4
Short flags are available:
./course-helper -m 3 -l 4
--module, -m: Module number or substring (e.g. 3, 3-functions)
--lesson, -l: Lesson number, suffix, or folder name (e.g. 4, 4-pass_by_value, pass_by_value)
--check, -c: Run static checks on the student file (gofmt -l and go vet)
--no-clean, -n: Keep temporary output files when the run completes (default is to clean)
--open, -o: Open exercise files in an editor (auto-detected; mutually exclusive with run/check)
--editor: Force the editor command (overrides detection)
--dry-run, -d: Print the commands that would be executed (for open and check modes)
- Locates the module under
course/using exact, prefix (<n>-...) or substring match. - Locates the exercise under
exercises/orchallenges/using exact name, prefix or substring. - Runs
go runoncode.go(student) andcomplete.go(solution). - Captures stdout, stderr and exit codes for each run.
- Normalizes outputs (trims trailing spaces and leading/trailing blank lines) and compares them with
diff -u. - Prints a short summary and exits with non-zero on mismatch.
Use --dry-run to see the commands that would be executed for either opening files or running checks.
Examples:
./course-helper -m 3 -l 4 --open --dry-run
./course-helper -m 3 -l 4 --dry-run
If a .env file exists at the repo root and contains EDITOR=..., the value there is preferred over
$VISUAL or $EDITOR when opening files.
- By default temporary files are removed. Use
--no-cleanto keep them for inspection. - If you want additional comparisons (e.g., compare only numbers or ignore ordering), I can add modes for that.