Files
routewatch/pkg/asinfo/doc.go
T
sneak 50283d9e9e
check / check (push) Canceled after 0s
Make the home page's AS name search work (closes #151)
The AS Name Search card on the home page said the search was coming
soon. It now asks the new GET /api/v1/search/as?q=<text>, which
searches the AS list built into asinfo, and lists the matches as links
to their AS pages. The answer holds the query, the number of matches
and the first 50 of them; an empty q answers 400. asinfo.Search now
ignores case, uses strings.Contains instead of its own substring loop,
and returns its matches in AS number order. A number, or AS and a
number, typed into the card still opens that AS's page. The card builds
the list with textContent, since the names come from outside data.

Model: opus-5-5
2026-10-26 20:21:14 +00:00

30 lines
910 B
Go

/*
Package asinfo provides information about Autonomous Systems (AS).
The package embeds a comprehensive database of AS numbers, handles, and descriptions
sourced from https://github.com/ipverse/asn-info. The data is embedded at compile
time and provides fast, offline lookups.
Basic usage:
// Get information about an AS
info, ok := asinfo.Get(15169)
if ok {
fmt.Printf("AS%d: %s - %s\n", info.ASN, info.Handle, info.Description)
}
// Get just the description
desc := asinfo.GetDescription(15169) // "Google LLC"
// Search the handles and descriptions, ignoring case; the matches come
// in AS number order
results := asinfo.Search("university")
for _, as := range results {
fmt.Printf("AS%d: %s\n", as.ASN, as.Description)
}
The data is loaded lazily on first access and cached in memory for the lifetime
of the program. All getter methods are safe for concurrent use.
*/
package asinfo