{"id":27613996,"url":"https://github.com/thatmattlove/go-asn","last_synced_at":"2025-07-19T13:09:31.448Z","repository":{"id":186249382,"uuid":"674889640","full_name":"thatmattlove/go-asn","owner":"thatmattlove","description":"Autonomous System Number Utility for Go","archived":false,"fork":false,"pushed_at":"2023-08-06T18:54:15.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T21:44:15.271Z","etag":null,"topics":["asn","bgp","network-automation","networking","routing-protocols"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause-clear","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thatmattlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-05T04:31:58.000Z","updated_at":"2024-12-28T15:32:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"2394d3d3-bc82-4b21-82c7-072543a7b682","html_url":"https://github.com/thatmattlove/go-asn","commit_stats":null,"previous_names":["thatmattlove/go-asn"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-asn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-asn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-asn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-asn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thatmattlove","download_url":"https://codeload.github.com/thatmattlove/go-asn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357039,"owners_count":21417194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asn","bgp","network-automation","networking","routing-protocols"],"created_at":"2025-04-23T02:28:28.560Z","updated_at":"2025-04-23T02:28:29.279Z","avatar_url":"https://github.com/thatmattlove.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ch3\u003e\n    \u003ccode\u003ego-asn\u003c/code\u003e\n\u003c/h3\u003e\n\u003cbr/\u003e\nAutonomous System Number Utility for Go\n\u003cbr/\u003e\n\u003cbr/\u003e\n    \u003ca href=\"https://github.com/thatmattlove/go-asn/actions/workflows/test.yml\"\u003e\n        \u003cimg alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/actions/workflow/status/thatmattlove/go-asn/test.yml?style=for-the-badge\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://app.codecov.io/gh/thatmattlove/go-asn\"\u003e\n        \u003cimg alt=\"Codecov\" src=\"https://img.shields.io/codecov/c/github/thatmattlove/go-asn?style=for-the-badge\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/thatmattlove/go-asn/tags\"\u003e\n        \u003cimg alt=\"GitHub tag (with filter)\" src=\"https://img.shields.io/github/v/tag/thatmattlove/go-asn?style=for-the-badge\u0026label=Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/thatmattlove/go-asn\"\u003e\n        \u003cimg alt=\"GoDoc Reference\" src=\"https://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge\"\u003e\n    \u003c/a\u003e\n\n\u003c/div\u003e\n\n## Installation\n\n```console\ngo get github.com/thatmattlove/go-asn\n```\n\n## Usage\n\n### Parsing\n\n```go\na, err := asn.Parse(\"65000\")\na, err := asn.FromDecimal(\"65000\")\na, err := asn.FromASDot(\"64086.59904\")\na, err := asn.FromUint64(65001)\na, err := asn.FromBytes(255, 255, 253, 232)\na := asn.From4Bytes(255, 255, 253, 232)\na := asn.From2Bytes(253, 232)\na := asn.FromUint32(65001)\na := asn.MustParse(\"65000\")\na := asn.MustDecimal(\"65000\")\na := asn.MustASDot(\"0.65000\")\n```\n\n### Formatting\n\n```go\na := asn.MustParse(\"65000\")\na.Size()\n// 2\na.ASPlain()\n// 65000\na.ASDot()\n// 65000\na.ASDotPlus()\n// 0.65000\na.String()\n// 65000\na.ByteString()\n// {0,0,253,232}\n\na = asn.MustParse(\"4200000000\")\na.Size()\n// 4\na.ASPlain()\n// 4200000000\na.ASDot()\n// 64086.59904\na.ASDotPlus()\n// 64086.59904\na.String()\n// 4200000000\na.ByteString()\n// {250,86,234,0}\n```\n\n### Comparison\n\n```go\na := asn.MustParse(\"65000\")\nb := asn.MustParse(\"65001\")\nc := asn.MustParse(\"65002\")\nd := asn.MustParse(\"65000\")\ne := asn.MustParse(\"64512\")\na.Equal(b)\n// false\na.Equal(d)\n// true\na.LessThan(b)\n// true\na.LEqual(c)\n// true\na.GreaterThan(e)\n// true\na.GEqual(e)\n// true\n```\n\n### Iteration\n\n```go\nstart := asn.MustParse(\"65000\")\nend := asn.MustParse(\"65005\")\n\nfor iter := start.Range(end); iter.Continue(); {\n    next := iter.Next()\n    fmt.Println(next.ASPlain())\n}\n// 65001\n// 65002\n// 65003\n// 65004\n// 65505\n\na := asn.MustParse(\"65000\")\nfor iter := a.Iter(); iter.Continue(); {\n    next := iter.Next()\n    fmt.Println(next.ASPlain())\n}\n// 65001\n// 65002\n// ...\n// 4294967294\n```\n\n![GitHub](https://img.shields.io/github/license/thatmattlove/go-asn?style=for-the-badge\u0026color=black)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatmattlove%2Fgo-asn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthatmattlove%2Fgo-asn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatmattlove%2Fgo-asn/lists"}