Adopt repo standards: scaffold, policies, lint-clean (closes #1)
check / check (push) Failing after 1s

Add the standard scaffold and bring the tree to a clean lint under the
vendored `default: all` config. New: `script/` Scripts-to-Rule-Them-All
entrypoints with the `Makefile` reduced to thin shims; a `Dockerfile`
whose `lint` and `test` phases gate the build (final stage depends on
both); a `.gitea/workflows/` CI running `script/cibuild`; the vendored
`.golangci.yml`; `REPO_POLICIES.md`; `.editorconfig`; `.dockerignore`; a
`LICENSE` (WTFPL) and `TODO.md`; and a comprehensive `.gitignore`.

The 211 lint findings were fixed, not suppressed: package-level state
became functions/fields/a command constructor, magic numbers became named
constants, `ctx` is threaded into the probes, the loop functions were
split to cut complexity, and the deprecated `+build` tags were dropped.
Behavior is unchanged. The only annotations are justified `//nolint:gosec`
on the `ping`/`curl` subprocess calls (G204, fixed argv) and the
operator-chosen log file (G304), matching the reference repos.

`make check` is green (lint and tests run in Docker).

Model: opus-4-8
This commit is contained in:
2026-09-21 06:57:21 +00:00
parent cf9dc39053
commit 499c03abbc
34 changed files with 2167 additions and 884 deletions
+50 -25
View File
@@ -1,6 +1,8 @@
# rtnetmon
Real-time network monitoring dashboard for Linux systems with dual-interface support.
rtnetmon is a WTFPL-licensed Go terminal (CLI/TUI) network monitor by
[@sneak](https://sneak.berlin) that shows real-time network health, packet
loss, and latency across two Linux network interfaces at once.
## Overview
@@ -34,13 +36,13 @@ for a clean, real-time dashboard interface.
```bash
git clone https://git.eeqj.de/sneak/rtnetmon.git
cd rtnetmon
make build
make build # produces ./bin/rtnetmon
```
## Usage
```bash
sudo ./rtnetmon --ifaceA eth0 --labelA "Primary WAN" --ifaceB wlan0 --labelB "Backup WiFi"
sudo ./bin/rtnetmon --ifaceA eth0 --labelA "Primary WAN" --ifaceB wlan0 --labelB "Backup WiFi"
```
### Command Line Options
@@ -60,41 +62,64 @@ sudo ./rtnetmon --ifaceA eth0 --labelA "Primary WAN" --ifaceB wlan0 --labelB "Ba
```
rtnetmon/
├── cmd/rtnetmon/ # Main entry point
├── cmd/rtnetmon/ # main entry point (thin: calls internal/cli)
│ └── main.go
├── internal/
│ ├── cli/ # Command-line interface using Cobra
│ ├── cli/ # command-line interface using Cobra
│ │ └── root.go
│ └── monitor/ # Core monitoring functionality
│ ├── monitor.go # Main monitoring types and functions
│ ├── loops.go # Monitoring loops (reachability, loss, TCP)
│ ├── styles.go # Terminal color styles
│ └── ui.go # User interface rendering
├── go.mod
├── go.sum
├── Makefile
│ └── monitor/ # core monitoring functionality
│ ├── monitor.go # monitor types, probes, logging
│ ├── loops.go # monitoring loops (reachability, loss, TCP)
│ ├── styles.go # terminal color styles
│ └── ui.go # user interface rendering
├── script/ # Scripts to Rule Them All entrypoints
├── .gitea/workflows/ # CI (runs script/cibuild)
├── Dockerfile # lint + test gate phases and the build
├── Makefile # thin shims over script/
├── .golangci.yml # vendored linter config
├── go.mod / go.sum
└── README.md
```
## Development
### Building
```bash
make build # Build the binary
make test # Run tests
make lint # Run linter
make fmt # Format code
make all # Format, lint, test, and build
make build # build ./bin/rtnetmon
make check # run tests, lint, and fmt-check (the default target)
make test # run the test suite (test phase of the Dockerfile)
make lint # run golangci-lint (lint phase of the Dockerfile)
make fmt # format Go code (writes)
make fmt-check # verify formatting (read-only)
make docker # build the Docker image
make hooks # install the git pre-commit hook
make dev # go run ./cmd/rtnetmon
make clean # remove build artifacts
```
### Testing
Linting and testing run in Docker so results do not depend on host tooling;
`make lint`, `make test`, `make docker`, and `make cibuild` therefore require
a Docker daemon. `make check` must be green before committing, and the
pre-commit hook (`make hooks`) runs it.
The project includes unit tests for core functionality. Run tests with:
## Entrypoints
```bash
make test
```
This repository adheres to the
[Scripts to Rule Them All](https://github.com/github/scripts-to-rule-them-all)
standard: normalized scripts in `script/` are the entrypoints for the
development workflow, and the Makefile targets are thin shims that call them.
- `script/bootstrap` — install dependencies idempotently (git, make, go).
- `script/setup` — bootstrap plus install the git pre-commit hook.
- `script/projectname` — output the project name.
- `script/test` — run the test suite as the Dockerfile `test` phase.
- `script/lint` — run golangci-lint as the Dockerfile `lint` phase.
- `script/fmt` — format Go code (host).
- `script/fmt-check` — verify formatting (host, read-only).
- `script/check` — run test, lint, and fmt-check.
- `script/docker` — build the Docker image.
- `script/cibuild` — bootstrap, check, and build the image; run by CI.
- `script/precommit` — run by the pre-commit hook (go mod tidy check + check).
- `script/install-precommit` — install the pre-commit hook.
### Using the Monitor API