Git Product home page Git Product logo

golspci's Introduction

golspci

golspci is a Go library that parses the output of the lspci command, make it easier to collect hardware info by program.
This library will call lspci -vmm -D to get canonical output for easier parsing.

Note

lspci provides -n flag, which show PCI vendor and device codes as numbers instead of looking them up in the PCI ID list. The code never change between different version of lspci, but name does. Pass vendorInNumber=true when calling lspci.New to get codes instead of name.

Usage

package main

import (
    "fmt"
    "github.com/xxr3376/golspci/lspci"
)

func main() {
    // vendorInNumber=false to get text version of vendor
    // vendorInNumber=true to get codes version of vendor
    l := lspci.New(false)

    if err := l.Run(); err != nil {
        panic(err)
    }

    fmt.Println(l.Data)
    // You will get something like:
    /* map[
        0000:7f:14.1:
            map[
                SVendor:Intel Corporation
                SDevice:Xeon E7 v3/Xeon E5 v3/Core i7 Integrated Memory Controller 0 Channel 1 Thermal Control
                Rev:02
                Slot:0000:7f:14.1
                Class:System peripheral
                Vendor:Intel Corporation
                Device:Xeon E7 v3/Xeon E5 v3/Core i7 Integrated Memory Controller 0 Channel 1 Thermal Control
            ]
        0000:ff:14.0:
            map[
        ...
     */
}

golspci's People

Contributors

xxr3376 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.