chore: initial scaffold for latprobe CLI tool

Sets up project structure, working conventions (CLAUDE.md), README with
the full assignment and roadmap, seeded CHANGELOG, and a buildable Go
scaffold (Step 0) with flag parsing and stub probe types.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 00:16:05 +02:00
commit 5717f018b7
9 changed files with 426 additions and 0 deletions

3
go/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module latprobe
go 1.26.4

View File

@@ -0,0 +1,34 @@
// Package probe measures per-phase HTTP request latency.
package probe
import "time"
// Phase holds the measured duration of a single request phase.
// A zero Duration means the phase did not occur (e.g. TLS on plain HTTP).
type Phase struct {
Duration time.Duration
// Present is false when the phase was skipped (e.g. no TLS for http://).
Present bool
}
// Result holds all timing phases for a single HTTP request.
type Result struct {
URL string
DNS Phase
Connect Phase
TLS Phase
TTFB Phase // server processing: WroteRequest → GotFirstResponseByte
Transfer Phase // body read: GotFirstResponseByte → body closed
Total Phase
// StatusCode is the HTTP response status code (0 on error).
StatusCode int
// Err is non-nil if the request failed.
Err error
}
// Measure performs an HTTP GET request to url and returns a populated Result.
// It is a placeholder until Step 1 wires in the actual implementation.
func Measure(url string) Result {
return Result{URL: url}
}

BIN
go/latprobe Executable file

Binary file not shown.

44
go/main.go Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"flag"
"fmt"
"os"
)
const usageText = `latprobe — measure per-phase HTTP request latency
Usage:
latprobe [flags] <url> [url ...]
Flags:
-n, --count int Number of requests per URL (default 1)
--json Output results as JSON instead of text
-h, --help Show this help
Examples:
latprobe https://example.com
latprobe -n 5 https://example.com https://www.google.com
latprobe --json https://example.com | jq .
`
func main() {
count := flag.Int("count", 1, "number of requests per URL")
flag.IntVar(count, "n", 1, "number of requests per URL (shorthand)")
jsonOut := flag.Bool("json", false, "output results as JSON")
flag.Usage = func() { fmt.Fprint(os.Stderr, usageText) }
flag.Parse()
urls := flag.Args()
if len(urls) == 0 {
fmt.Fprint(os.Stderr, usageText)
os.Exit(1)
}
// Placeholders — implementations wired in per step.
_, _ = count, jsonOut
fmt.Fprintf(os.Stderr, "latprobe: not yet implemented (scaffold only)\n")
os.Exit(1)
}