{"id":27614018,"url":"https://github.com/thatmattlove/go-macaddr","last_synced_at":"2025-04-23T02:28:57.570Z","repository":{"id":57649675,"uuid":"446612888","full_name":"thatmattlove/go-macaddr","owner":"thatmattlove","description":"MAC Address \u0026 Prefix Utility for Go","archived":false,"fork":false,"pushed_at":"2024-08-02T19:17:46.000Z","size":70,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T03:43:25.032Z","etag":null,"topics":["go","mac-address","network"],"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}},"created_at":"2022-01-10T23:22:29.000Z","updated_at":"2024-12-22T17:25:15.000Z","dependencies_parsed_at":"2022-09-05T13:21:46.798Z","dependency_job_id":null,"html_url":"https://github.com/thatmattlove/go-macaddr","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-macaddr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-macaddr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-macaddr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatmattlove%2Fgo-macaddr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thatmattlove","download_url":"https://codeload.github.com/thatmattlove/go-macaddr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357144,"owners_count":21417212,"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":["go","mac-address","network"],"created_at":"2025-04-23T02:28:57.050Z","updated_at":"2025-04-23T02:28:57.554Z","avatar_url":"https://github.com/thatmattlove.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n### `macaddr`\n\nMAC Address \u0026 Prefix Utility for Go\n\n[![Docs](https://img.shields.io/badge/godoc-reference-007D9C.svg?style=for-the-badge)](https://pkg.go.dev/go.mdl.wtf/go-macaddr)\n\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/thatmattlove/go-macaddr/test.yml?style=for-the-badge)](https://github.com/thatmattlove/go-macaddr/actions/workflows/test.yml) [![Test Coverage](https://img.shields.io/coverallsCoverage/github/thatmattlove/go-macaddr?style=for-the-badge)](https://coveralls.io/github/thatmattlove/go-macaddr) [![Go Report Card](https://goreportcard.com/badge/github.com/thatmattlove/go-macaddr?style=for-the-badge)](https://goreportcard.com/report/github.com/thatmattlove/go-macaddr)\n\n\u003c/div\u003e\n\n## Installation\n\n```\ngo get -d go.mdl.wtf/go-macaddr/go-macaddr\n```\n\n## Usage\n\n### Single MAC Address\n\n```go\nmac, err := macaddr.ParseMACAddress(\"00:00:5e:00:53:ab\")\nif err != nil {\n    panic(err)\n}\n\nmac.ByteString()\n// {0,0,94,0,83,171}\nmac.Clone()\n// MACAddress{0,0,0x5e,0,53,0xab}\nmac.Dashes()\n// 00-00-5e-00-53-ab\nmac.Dots()\n// 0000.5e00.53ab\nmac.Equal(MACAddress{0,0,0x5e,0,53,0xab})\n// true\nmac.Format(\"xxx_xxx_xxx_xxx\")\n// 000_05e_005_3ab\nmac.GEqual(MACAddress{0,0,0x5e,0,53,0xac})\n// false\nmac.Greater(MACAddress{0,0,0x5e,0,53,0xaa})\n// true\nmac.Int()\n// 1577079723\nmac.LEqual(MACAddress{0,0,0x5e,0,53,0xac})\n// true\nmac.Lesser(MACAddress{0,0,0x5e,0,53,0xaa})\n// false\nmac.Mask(MACAddress{0xff,0xff,0xff,0xff,0xff,0})\n// MACAddress{0,0,0x5e,0,0x53,0}\nmac.Next()\n// MACAddress{0,0,0x5e,0,0x53,0xac}\nmac.NoSeparators()\n// 00005e0053ab\nmac.OUI()\n// 00:00:5e\nmac.Previous()\n// MACAddress{0,0,0x5e,0,0x53,0xaa}\nmac.String()\n// 00:00:5e:00:53:ab\n```\n\n### MAC Prefix\n\n```go\nmac, prefix, err := macaddr.ParseMACPrefix(\"00:00:5e:00:00:00/24\")\n\nif err != nil {\n    panic(err)\n}\n\nprefix.Count()\n// 16777216\nprefix.First()\n// MACAddress{0,0,0x5e,0,0,0}\niter := prefix.Iter()\nfor iter.Next() {\n    iter.Value()\n}\n// MACAddress{0,0,0x5e,0,0,0}\n// MACAddress{0,0,0x5e,0,0,1}\n// MACAddress{0,0,0x5e,0,0,2}\n// ...\nmatch, err := prefix.Match(\"00:00:5e:01:23:45\")\nmatch.String()\n// 00:00:5e:00:00:00/24\nmatch, err = prefix.Match(\"00:00:5f:01:23:45\")\nerr.Error()\n// '00:00:5f:01:23:45' is not contained within MACPrefix 00:00:5e:00:00:00/24\nprefix.OUI()\n// 00:00:5e\nprefix.PrefixLen()\n// 24\nprefix.String()\n// 00:00:5e:00:00:00/24\nprefix.WildcardMask()\n// MACPrefix{0,0,0,0xff,0xff,0xff}\n```\n\n## Roadmap\n\nDepending on if others find this library useful, EUI-64 support may be added. Please open an issue if you would find this helpful.\n\n![GitHub](https://img.shields.io/github/license/thatmattlove/go-macaddr?color=000\u0026style=for-the-badge)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatmattlove%2Fgo-macaddr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthatmattlove%2Fgo-macaddr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatmattlove%2Fgo-macaddr/lists"}