Development Guide¶
Requirements¶
- Go 1.26+
- Node.js 22+ to run the browser-helper tests (not needed to build or run memdroid)
- macOS, Linux, or Windows (host PC)
- pre-commit for local hooks
Setup¶
git clone https://github.com/qusamulab/memdroid.git
cd memdroid
go mod download
# Install pre-commit hooks
brew install pre-commit # or: pip install pre-commit
pre-commit install
Build¶
Pre-commit Hooks¶
Configured in .pre-commit-config.yaml:
| Hook | What it does |
|---|---|
go-fmt |
Formats all .go files with gofmt |
go-vet |
Runs go vet ./... |
go-imports |
Cleans up import blocks with goimports |
golangci-lint |
Runs linters defined in .golangci.yml |
Run manually at any time:
Linter config: .golangci.yml
Enabled: gofmt, goimports, govet, errcheck, staticcheck
Verification¶
go test -race -count=1 ./...
go vet ./...
go build ./...
node --test internal/webui/tests/*.test.mjs
Go tests use an in-memory driver, so an Android device and adb are not
required. UI asset tests walk the embedded module graph and verify that every
referenced file is served with browser-compatible MIME types. The Node tests
cover API errors and escaping of dynamic action arguments.
For visual checks, run go run ./cmd/memdroid and open the displayed URL.
Check device selection, attach, search/filter, candidate pagination, editing
and undo at desktop and narrow widths. An absent adb or device should display
an actionable error in the device list.
Adding a New Feature¶
- Put reusable behavior in the appropriate package:
internal/app/— operations shared by CLI and HTTP, process lifecycleinternal/memory/search/— scanning and filteringinternal/memory/modify/— writes, undo, freeze, snapshots and dumpsinternal/memory/watch/— background monitoringinternal/memory/store/— bookmarks, imports and file formats-
internal/driver/adb/— ADB transport -
Add CLI prompts/output to the matching file in
internal/cli/and register its key, label and action together inmenu.go. -
Add HTTP handlers to
internal/server/handlers_<resource>.goand register their paths inroutes.go. Keep resource tests beside the handlers. -
Add browser actions to a feature module under
internal/webui/static/js/. Register new modules inapp.js, use declarative action attributes in the markup, and keep styling instyles.css. Assets are embedded automatically; restart the Go server and reload the browser after editing them. -
Update Usage, API Reference and Architecture when behavior or structure changes.
Commit Convention¶
Write descriptive commit messages. Format:
Example: