mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
* feat: Add opt-in support for proxy CA cert installation * fix: Code review fixes * fix: Code review fixes * fix: Code review fixes * fix: Code review fixes * fix: Code review fixes * docs: Add limitation for MacOS MDM script
2.0 KiB
2.0 KiB
PMG - Development Guide
Build & Test
go build ./... # Build
go test ./... -count=1 # Run all tests
go test ./config/ -v -count=1 # Run specific package tests
Project Structure
cmd/— CLI commands (npm, pypi, setup, version)config/— Configuration loading, templates, mergingsandbox/— Sandbox policy enforcement (macOS Seatbelt, Linux Bubblewrap)proxy/— Proxy-based package interceptionguard/— Guard-based package analysisanalyzer/— Package security analysisinternal/— Internal utilities (analytics, eventlog, flows, ui)
Code Style
- Keep things short and simple
- Avoid unnecessary code comments
- Use comments for trade-offs, known uncovered cases, and anything useful for a human reader
- Code itself should be readable without comments explaining the obvious
- Follow existing patterns in the codebase
- Use
testify(assert/require) for test assertions — do not use rawifchecks witht.Errorf/t.Fatalf - Use
requirefor assertions that should stop the test on failure (e.g. nil error checks before using a value) - Use
assertfor assertions where the test can continue after failure - Table-driven tests preferred
Code Reuse
- Follow DRY — do not duplicate code
- Prefer refactoring existing code for reusability over copying and modifying
- Extract shared logic into functions or packages when patterns repeat
Error Handling
- Never swallow errors — always handle them explicitly
- Prefer failing fast by returning errors up the call stack
- When soft failure is acceptable, log with
log.Warnffromgithub.com/safedep/dry/log - Do not use
_ = someFunc()to discard errors silently - For CLI/user-facing errors, prefer
usefulerrorwith a specific code and actionable help soui.ErrorExitdoes not classify expected failures asUnknown - Check the error from
fmt.Fprintf/fmt.Fprintln/fmt.Fprint(theerrchecklinter flags these). Return it up the stack:if _, err := fmt.Fprintf(out, ...); err != nil { return err }