feat(go): step 1 — total wall-clock latency per URL
probe.Measure performs an HTTP GET and records total elapsed time from request start to body fully read. main.go prints URL, status code, and total for each positional URL argument, exiting 1 on any failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
24
go/main.go
24
go/main.go
@@ -4,6 +4,9 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"latprobe/internal/probe"
|
||||
)
|
||||
|
||||
const usageText = `latprobe — measure per-phase HTTP request latency
|
||||
@@ -36,9 +39,22 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Placeholders — implementations wired in per step.
|
||||
_, _ = count, jsonOut
|
||||
// --json and -n are parsed but not yet functional (wired in Steps 3–4).
|
||||
_ = jsonOut
|
||||
_ = count
|
||||
|
||||
fmt.Fprintf(os.Stderr, "latprobe: not yet implemented (scaffold only)\n")
|
||||
os.Exit(1)
|
||||
failed := false
|
||||
for _, url := range urls {
|
||||
r := probe.Measure(url)
|
||||
if r.Err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error %s: %v\n", url, r.Err)
|
||||
failed = true
|
||||
continue
|
||||
}
|
||||
fmt.Printf("%-45s %d %v\n", r.URL, r.StatusCode, r.Total.Duration.Round(time.Millisecond))
|
||||
}
|
||||
|
||||
if failed {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user