{"id":17316011,"url":"https://github.com/hertg/gopci","last_synced_at":"2026-05-01T15:39:16.556Z","repository":{"id":51166071,"uuid":"519488936","full_name":"hertg/gopci","owner":"hertg","description":":computer: :mag: go library parsing linux pci information from sysfs","archived":false,"fork":false,"pushed_at":"2022-10-10T18:56:57.000Z","size":359,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T07:18:55.494Z","etag":null,"topics":["go","golang","hacktoberfest","hwinfo","library","linux","pci","sysfs"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hertg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["hertg"]}},"created_at":"2022-07-30T10:43:47.000Z","updated_at":"2023-11-27T16:25:54.000Z","dependencies_parsed_at":"2022-08-12T22:50:31.032Z","dependency_job_id":null,"html_url":"https://github.com/hertg/gopci","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/hertg%2Fgopci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hertg%2Fgopci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hertg%2Fgopci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hertg%2Fgopci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hertg","download_url":"https://codeload.github.com/hertg/gopci/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245767157,"owners_count":20668822,"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","golang","hacktoberfest","hwinfo","library","linux","pci","sysfs"],"created_at":"2024-10-15T13:11:19.320Z","updated_at":"2026-05-01T15:39:16.454Z","avatar_url":"https://github.com/hertg.png","language":"Go","funding_links":["https://github.com/sponsors/hertg"],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003cstrong\u003egopci\u003c/strong\u003e\u003c/h1\u003e\n  \u003cp\u003e\n\t\t\u003cstrong\u003eA minimal and fast library to parse pci device info from sysfs.\u003c/strong\u003e\n  \u003c/p\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/hertg/gopci\"\u003e\n      \u003cimg alt=\"Go Report Card\" src=\"https://goreportcard.com/badge/github.com/hertg/gopci\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"#\"\u003e\n\t\t\t\u003cimg alt=\"License Information\" src=\"https://img.shields.io/github/license/hertg/go-pciids\"\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## Description\n\nThis library provides methods to get PCI information on a linux system.\nIt has been created as a minimalistic and more performant alternative to\nthe pci parsing capabilities of [jaypipes/ghw](https://github.com/jaypipes/ghw).\n\nIf you need non-pci or non-linux hardware information,\nghw offers an all-in-one solution. If you simply care about linux pci information,\nthis library offers a **significant performance benefit** over ghw (see [comparison](#Comparison)).\n\n## Usage\n\n### Install\n```shell\ngo get github.com/hertg/gopci\n```\n\n### Scan\n```go\ndevices, _ := pci.Scan()\nfor _, device := range devices {\n\t// ...\n}\n```\n\nThe `Device` struct contains information like `Vendor`, `Device`, `Class`, `Subvendor`, `Subdevice`, etc.\nMore detailed information is made available in the `Config` field which contains the raw parsed PCI config header.\n\nIf more information from sysfs shall be processed, the `SysfsPath()` method can be used\nto get a direct link to the PCI devices sysfs path which can be used for further custom information gathering.\n\n### Filter\nThe `Scan()` method allows optional `Filter` arguments to only include matching\ndevices in the resulting list of devices.\n\n```go\nclassFilter := func(d *pci.Device) bool { return d.Class.Class == 0x03 }\ndevices, _ := pci.Scan(classFilter)\n```\n\n## Comparison\n\nDevice configuration is parsed directly as bytes (from `config`) instead of\nreading strings and parsing from there. This prevents unnecessary string\nallocationis and significantly improves performance.\n\nIt has been found that this library parses at more\nthan 10x the speed while using 50x less memory compared to\n[jaypipes/ghw](https://github.com/jaypipes/ghw).\n\n```text\ngoos: linux\ngoarch: amd64\npkg: github.com/hertg/gopci/pkg/pci\ncpu: AMD Ryzen 9 5950X 16-Core Processor\nBenchmarkGoPci\nBenchmarkGoPci-32            518           2554827 ns/op          297709 B/op       5178 allocs/op\nBenchmarkGhw\nBenchmarkGhw-32               34          33286659 ns/op        15745188 B/op     201189 allocs/op\nPASS\nok      github.com/hertg/gopci/pkg/pci  2.802s\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhertg%2Fgopci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhertg%2Fgopci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhertg%2Fgopci/lists"}