Check a Go Package's Health Before You Import It
oc is a token-efficient, key-free web-browsing CLI built for AI agents: it renders any page as a compact, numbered JSON view instead of raw HTML. Its `oc go pkg` shortcut resolves straight to a package's pkg.go.dev page, and jq pulls out the license, publish date, and import counts — a five-second gut check before you add a dependency.
Setup
- → npm install -g @only-cli/oc # or run without installing: npx @only-cli/oc
Cost per run
free
The one-liner
$ oc go pkg golang.org/x/sync/errgroup --json \
| jq -r '
.title,
(.blocks[] | select(.text? and (.text | test("^(Published|Imports|Imported by):"))) | .text)
'What each stage does
- [01] oc
oc go pkg golang.org/x/sync/errgroup --jsonRenders the pkg.go.dev page for the given import path as a numbered, budget-capped JSON view. The `oc go pkg <path>` site shortcut resolves straight to the right URL, so the agent (or you) never has to know how pkg.go.dev spells its own links. - [02] jq
.titleoc's JSON is a flat `blocks` array of the page's numbered regions, with the page title as a top-level field; grab that first so the output opens with the package name. - [03] jq
(.blocks[] | select(.text? and (.text | test("^(Published|Imports|Imported by):"…Scans the `blocks` array for the three metadata lines that matter — publish date + license, import count, imported-by count — and skips everything else on the page (nav links, buttons, the full doc body).
Expected output (sample)
errgroup package - golang.org/x/sync/errgroup - Go Packages Published: Jul 1, 2026 License: Imports: 3 Imported by: 30,110
Caveats & tips
- Verified with @only-cli/oc 0.5.0 and jq 1.7.1. In the sandbox used to verify this, oc's optional `impers` dependency (browser TLS fingerprinting) threw "Impersonating chrome150 is not supported" at runtime instead of the silent native-fetch fallback its own docs describe; removing it (`npm rm -g impers`, or installing with `--omit=optional`) fixed it and produced this output. Most desktop/laptop installs should get a working impers build with nothing extra; if `oc open` errors the same way, the same workaround applies.
- The `blocks` JSON shape is oc's internal render format, not a documented stable API — pin an oc version if you script against field names.
- The same `oc <site> <verb> --json | jq` shape works across oc's 20+ built-in site shortcuts (`oc hn top --json`, `oc gh repo <owner> <name> --json`, `oc wiki search <query> --json`, ...) — swap the site and the jq filter, keep the pattern.